Re: [PATCH] Memory leak in mtd/chips/cfi_cmdset_0020

From: Felipe W Damasio
Date: Mon Oct 06 2003 - 09:52:44 EST




David Woodhouse wrote:
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.

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 --- linux-2.6.0-test6/drivers/mtd/chips/cfi_cmdset_0020.c.orig 2003-10-06 11:37:31.000000000 -0300
+++ linux-2.6.0-test6/drivers/mtd/chips/cfi_cmdset_0020.c 2003-10-06 11:52:40.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;
}