]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] uml: close file descriptor leaks
authorJeff Dike <jdike@addtoit.com>
Fri, 29 Sep 2006 08:58:51 +0000 (01:58 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 29 Sep 2006 16:18:04 +0000 (09:18 -0700)
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>
arch/um/drivers/ubd_kern.c
arch/um/os-Linux/mem.c

index 34085315aa57e045232a20abeea45ec1111dda79..5fa4c8e258a4e4d76d9406b5e002589e6c042374 100644 (file)
@@ -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,
@@ -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;
 }
index b170b4704dc40aa25137f6ab29ece4b36eb03078..4203681e508d0a680635347c53a2168fdd3a68be 100644 (file)
@@ -132,6 +132,9 @@ err:
        else if(found < 0)
                printf("read returned errno %d\n", -found);
 
+out:
+       close(fd);
+
        return;
 
 found:
@@ -141,11 +144,12 @@ found:
 
        if(strncmp(buf, "tmpfs", strlen("tmpfs"))){
                printf("not tmpfs\n");
-               return;
+               goto out;
        }
 
        printf("OK\n");
        default_tmpdir = "/dev/shm";
+       goto out;
 }
 
 /*