[PATCH] do_mounts memory leak

From: Randy.Dunlap (randy.dunlap@verizon.net)
Date: Wed Feb 05 2003 - 16:39:30 EST


Hi,

The Stanford Checker identified a memory leak in
init/do_mounts.c. This patch to 2.5.59 corrects it.
Please apply.

Thanks,
~Randy

diff -Naur ./init/do_mounts.c%LEAK ./init/do_mounts.c
--- ./init/do_mounts.c%LEAK Thu Jan 16 18:22:02 2003
+++ ./init/do_mounts.c Tue Feb 4 21:46:58 2003
@@ -653,12 +653,6 @@
         /*
          * OK, time to copy in the data
          */
- buf = kmalloc(BLOCK_SIZE, GFP_KERNEL);
- if (buf == 0) {
- printk(KERN_ERR "RAMDISK: could not allocate buffer\n");
- goto done;
- }
-
         if (sys_ioctl(in_fd, BLKGETSIZE, (unsigned long)&devblocks) < 0)
                 devblocks = 0;
         else
@@ -669,6 +663,12 @@
 
         if (devblocks == 0) {
                 printk(KERN_ERR "RAMDISK: could not determine device size\n");
+ goto done;
+ }
+
+ buf = kmalloc(BLOCK_SIZE, GFP_KERNEL);
+ if (buf == 0) {
+ printk(KERN_ERR "RAMDISK: could not allocate buffer\n");
                 goto done;
         }
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Feb 07 2003 - 22:00:18 EST