aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2006-09-29 04:58:51 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-29 12:18:04 -0400
commit80c13749140284abdc23bbeed2507b7e5a3dc459 (patch)
tree9d5a56f718e8f467af3daf0089309d3b1ac9d12e /arch/um
parent730760e90a173ef81f89beed2f1dad2fab310f68 (diff)
[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: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/drivers/ubd_kern.c9
-rw-r--r--arch/um/os-Linux/mem.c6
2 files changed, 7 insertions, 8 deletions
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 34085315aa57..5fa4c8e258a4 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -668,18 +668,15 @@ static int ubd_add(int n)
668 if(dev->file == NULL) 668 if(dev->file == NULL)
669 goto out; 669 goto out;
670 670
671 if (ubd_open_dev(dev))
672 goto out;
673
674 err = ubd_file_size(dev, &dev->size); 671 err = ubd_file_size(dev, &dev->size);
675 if(err < 0) 672 if(err < 0)
676 goto out_close; 673 goto out;
677 674
678 dev->size = ROUND_BLOCK(dev->size); 675 dev->size = ROUND_BLOCK(dev->size);
679 676
680 err = ubd_new_disk(MAJOR_NR, dev->size, n, &ubd_gendisk[n]); 677 err = ubd_new_disk(MAJOR_NR, dev->size, n, &ubd_gendisk[n]);
681 if(err) 678 if(err)
682 goto out_close; 679 goto out;
683 680
684 if(fake_major != MAJOR_NR) 681 if(fake_major != MAJOR_NR)
685 ubd_new_disk(fake_major, dev->size, n, 682 ubd_new_disk(fake_major, dev->size, n,
@@ -691,8 +688,6 @@ static int ubd_add(int n)
691 make_ide_entries(ubd_gendisk[n]->disk_name); 688 make_ide_entries(ubd_gendisk[n]->disk_name);
692 689
693 err = 0; 690 err = 0;
694out_close:
695 ubd_close(dev);
696out: 691out:
697 return err; 692 return err;
698} 693}
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
index b170b4704dc4..4203681e508d 100644
--- a/arch/um/os-Linux/mem.c
+++ b/arch/um/os-Linux/mem.c
@@ -132,6 +132,9 @@ err:
132 else if(found < 0) 132 else if(found < 0)
133 printf("read returned errno %d\n", -found); 133 printf("read returned errno %d\n", -found);
134 134
135out:
136 close(fd);
137
135 return; 138 return;
136 139
137found: 140found:
@@ -141,11 +144,12 @@ found:
141 144
142 if(strncmp(buf, "tmpfs", strlen("tmpfs"))){ 145 if(strncmp(buf, "tmpfs", strlen("tmpfs"))){
143 printf("not tmpfs\n"); 146 printf("not tmpfs\n");
144 return; 147 goto out;
145 } 148 }
146 149
147 printf("OK\n"); 150 printf("OK\n");
148 default_tmpdir = "/dev/shm"; 151 default_tmpdir = "/dev/shm";
152 goto out;
149} 153}
150 154
151/* 155/*