Memory leak in mtd/chips/cfi_cmdset_0020
PATCH 1/1 Memory leak in mtd/chips/cfi_cmdset_0020
Hi David,
Patch against 2.6.0-test6.
- Frees a previous allocated kmalloced variable before returning NULL;
Found by smatch.
Please consider applying,
Felipe
drivers/mtd/chips/cfi_cmdset_0020.c renamed from drivers/mtd/chips/cfi_cmdset_0020.c.orig +1 -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 ; }
David Woodhouse
AppliedQuoted 7 lines · Felipe W Damasio
Hi David,
Patch against 2.6.0-test6.
- Frees a previous allocated kmalloced variable before returning NULL;
Found by smatch.
Applied; thanks. It'll be in the next update sent to Linus, when I get a few spare moments for merging and testing.
Out of interest, why didn't smatch also find the same error 25 lines further down?
Signature · 1 line
dwmw2
Quoted 2 lines · David Woodhouse
Applied; thanks. It'll be in the next update sent to Linus, when I get a few spare moments for merging and testing.
Great, thanks.
Quoted 2 lines
Out of interest, why didn't smatch also find the same error 25 lines further down?
He did...I didn't ;) If you want, updated patch is attached. Cheers,
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 1 line · Felipe W Damasio
He did...I didn't ;)
Heh, OK.
Quoted 1 line
If you want, updated patch is attached.
I'd already done it, but thanks.
Signature · 1 line
dwmw2