lkml.org 
[lkml]   [2003]   [Sep]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] Memory leak in mtd/chips/cfi_cmdset_0020.c
	Hi Andrew,

Patch against 2.6-test5.

If other kmallocs failed after successfully allocating a "struct
mtd_info", it should be freed before returning NULL.

This function is called by inter_module_register...so I'm not sure it
should really be freed...please review :)

Don't have the hardware, so just compilation checked.

Found by the Stanford Checker.

Thanks,

Felipe
--- linux-2.6.0-test5/drivers/mtd/chips/cfi_cmdset_0020.c.orig 2003-09-23 16:15:35.000000000 -0300
+++ linux-2.6.0-test5/drivers/mtd/chips/cfi_cmdset_0020.c 2003-09-23 16:18:48.000000000 -0300
@@ -208,6 +208,7 @@
if (!mtd->eraseregions) {
printk(KERN_ERR "Failed to allocate memory for MTD erase region info\n");
kfree(cfi->cmdset_priv);
+ kfree(mtd);
return NULL;
}

@@ -232,6 +233,7 @@
printk(KERN_WARNING "Sum of regions (%lx) != total size of set of interleaved chips (%lx)\n", offset, devsize);
kfree(mtd->eraseregions);
kfree(cfi->cmdset_priv);
+ kfree(mtd);
return NULL;
}
\
 
 \ /
  Last update: 2005-03-22 13:48    [W:0.026 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site