提交 80c13749 编写于 作者: J Jeff Dike 提交者: Linus Torvalds

[PATCH] uml: close file descriptor leaks

Close two file descriptor leaks, one in the ubd driver and one to
/proc/mounts.  The ubd driver bug also leaked some vmalloc space.  The
/proc/mounts leak was a descriptor that was just never closed.
Signed-off-by: NJeff Dike <jdike@addtoit.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 730760e9
...@@ -668,18 +668,15 @@ static int ubd_add(int n) ...@@ -668,18 +668,15 @@ static int ubd_add(int n)
if(dev->file == NULL) if(dev->file == NULL)
goto out; goto out;
if (ubd_open_dev(dev))
goto out;
err = ubd_file_size(dev, &dev->size); err = ubd_file_size(dev, &dev->size);
if(err < 0) if(err < 0)
goto out_close; goto out;
dev->size = ROUND_BLOCK(dev->size); dev->size = ROUND_BLOCK(dev->size);
err = ubd_new_disk(MAJOR_NR, dev->size, n, &ubd_gendisk[n]); err = ubd_new_disk(MAJOR_NR, dev->size, n, &ubd_gendisk[n]);
if(err) if(err)
goto out_close; goto out;
if(fake_major != MAJOR_NR) if(fake_major != MAJOR_NR)
ubd_new_disk(fake_major, dev->size, n, ubd_new_disk(fake_major, dev->size, n,
...@@ -691,8 +688,6 @@ static int ubd_add(int n) ...@@ -691,8 +688,6 @@ static int ubd_add(int n)
make_ide_entries(ubd_gendisk[n]->disk_name); make_ide_entries(ubd_gendisk[n]->disk_name);
err = 0; err = 0;
out_close:
ubd_close(dev);
out: out:
return err; return err;
} }
......
...@@ -132,6 +132,9 @@ static void which_tmpdir(void) ...@@ -132,6 +132,9 @@ static void which_tmpdir(void)
else if(found < 0) else if(found < 0)
printf("read returned errno %d\n", -found); printf("read returned errno %d\n", -found);
out:
close(fd);
return; return;
found: found:
...@@ -141,11 +144,12 @@ static void which_tmpdir(void) ...@@ -141,11 +144,12 @@ static void which_tmpdir(void)
if(strncmp(buf, "tmpfs", strlen("tmpfs"))){ if(strncmp(buf, "tmpfs", strlen("tmpfs"))){
printf("not tmpfs\n"); printf("not tmpfs\n");
return; goto out;
} }
printf("OK\n"); printf("OK\n");
default_tmpdir = "/dev/shm"; default_tmpdir = "/dev/shm";
goto out;
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册