2003-09-23 19:57:19

by Felipe W Damasio

[permalink] [raw]
Subject: [PATCH] Memory leak in mtd/chips/cfi_cmdset_0020.c

--- 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;
}


Attachments:
cfi-0020-leak.patch (620.00 B)

2003-09-23 20:54:04

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] Memory leak in mtd/chips/cfi_cmdset_0020.c

Felipe W Damasio <[email protected]> wrote:
>
> This function is called by inter_module_register...so I'm not sure it
> should really be freed...please review :)

Is fine, thanks.

2003-09-23 20:37:39

by Jörn Engel

[permalink] [raw]
Subject: Re: [PATCH] Memory leak in mtd/chips/cfi_cmdset_0020.c

On Tue, 23 September 2003 16:25:01 -0300, Felipe W Damasio wrote:
>
> 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

--
A defeated army first battles and then seeks victory.
-- Sun Tzu