Skip to content

Commit

Permalink
[PATCH] uml: close file descriptor leaks
Browse files Browse the repository at this point in the history
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: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Jeff Dike authored and Linus Torvalds committed Sep 29, 2006
1 parent 730760e commit 80c1374
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 2 additions & 7 deletions arch/um/drivers/ubd_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,18 +668,15 @@ static int ubd_add(int n)
if(dev->file == NULL)
goto out;

if (ubd_open_dev(dev))
goto out;

err = ubd_file_size(dev, &dev->size);
if(err < 0)
goto out_close;
goto out;

dev->size = ROUND_BLOCK(dev->size);

err = ubd_new_disk(MAJOR_NR, dev->size, n, &ubd_gendisk[n]);
if(err)
goto out_close;
goto out;

if(fake_major != MAJOR_NR)
ubd_new_disk(fake_major, dev->size, n,
Expand All @@ -691,8 +688,6 @@ static int ubd_add(int n)
make_ide_entries(ubd_gendisk[n]->disk_name);

err = 0;
out_close:
ubd_close(dev);
out:
return err;
}
Expand Down
6 changes: 5 additions & 1 deletion arch/um/os-Linux/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ static void which_tmpdir(void)
else if(found < 0)
printf("read returned errno %d\n", -found);

out:
close(fd);

return;

found:
Expand All @@ -141,11 +144,12 @@ static void which_tmpdir(void)

if(strncmp(buf, "tmpfs", strlen("tmpfs"))){
printf("not tmpfs\n");
return;
goto out;
}

printf("OK\n");
default_tmpdir = "/dev/shm";
goto out;
}

/*
Expand Down

0 comments on commit 80c1374

Please sign in to comment.