Memory leak in mtd/chips/cfi_cmdset_0020.c
PATCH 1/1 Memory leak in mtd/chips/cfi_cmdset_0020.c
Hi Andrew,
Patch against 2.6-test5.
If other kmallocs failed after successfully allocating a "structmtd_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
drivers/mtd/chips/cfi_cmdset_0020.c renamed from drivers/mtd/chips/cfi_cmdset_0020.c.orig +2 -0
@@ -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 ; }
Quoted 10 lines · Felipe W Damasio
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.
Very few people do, STMicro sells those chips to a handpicked group of users only. And none of them use 2.6 yet, to my knowledge. But your patch looks fine, so please do apply, Andrew and David.
Jörn
Signature · 2 lines
A defeated army first battles and then seeks victory. -- Sun Tzu
Quoted 3 lines · Felipe W Damasio
This function is called by inter_module_register...so I'm not sure it
should really be freed...please review :)
Is fine, thanks.