public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] Memory leak in mtd/chips/cfi_cmdset_0020
@ 2003-10-06 14:45 Felipe W Damasio
  2003-10-06 14:46 ` David Woodhouse
  0 siblings, 1 reply; 4+ messages in thread
From: Felipe W Damasio @ 2003-10-06 14:45 UTC (permalink / raw)
  To: dwmw2; +Cc: linux-mtd, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 168 bytes --]

	Hi David,

	Patch against 2.6.0-test6.

	- Frees a previous allocated kmalloced variable before returning NULL;

	Found by smatch.

	Please consider applying,

Felipe

[-- Attachment #2: cfi_cmdset_0020-leak.patch --]
[-- Type: text/plain, Size: 385 bytes --]

--- 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:37:50.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;
 	}
 	

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Memory leak in mtd/chips/cfi_cmdset_0020
  2003-10-06 14:45 [PATCH] Memory leak in mtd/chips/cfi_cmdset_0020 Felipe W Damasio
@ 2003-10-06 14:46 ` David Woodhouse
  2003-10-06 14:54   ` Felipe W Damasio
  0 siblings, 1 reply; 4+ messages in thread
From: David Woodhouse @ 2003-10-06 14:46 UTC (permalink / raw)
  To: Felipe W Damasio; +Cc: linux-mtd, Linux Kernel Mailing List

On Mon, 2003-10-06 at 11:45 -0300, Felipe W Damasio wrote:
> 	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?

-- 
dwmw2

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Memory leak in mtd/chips/cfi_cmdset_0020
  2003-10-06 14:54   ` Felipe W Damasio
@ 2003-10-06 14:52     ` David Woodhouse
  0 siblings, 0 replies; 4+ messages in thread
From: David Woodhouse @ 2003-10-06 14:52 UTC (permalink / raw)
  To: Felipe W Damasio; +Cc: linux-mtd, Linux Kernel Mailing List

On Mon, 2003-10-06 at 11:54 -0300, Felipe W Damasio wrote:
> 	He did...I didn't ;)

Heh, OK. 

> 	If you want, updated patch is attached.

I'd already done it, but thanks.

-- 
dwmw2

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Memory leak in mtd/chips/cfi_cmdset_0020
  2003-10-06 14:46 ` David Woodhouse
@ 2003-10-06 14:54   ` Felipe W Damasio
  2003-10-06 14:52     ` David Woodhouse
  0 siblings, 1 reply; 4+ messages in thread
From: Felipe W Damasio @ 2003-10-06 14:54 UTC (permalink / raw)
  To: David Woodhouse; +Cc: linux-mtd, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 333 bytes --]



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

[-- Attachment #2: cfi_cmdset_0020-leak.patch --]
[-- Type: text/plain, Size: 620 bytes --]

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-10-06 14:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-06 14:45 [PATCH] Memory leak in mtd/chips/cfi_cmdset_0020 Felipe W Damasio
2003-10-06 14:46 ` David Woodhouse
2003-10-06 14:54   ` Felipe W Damasio
2003-10-06 14:52     ` David Woodhouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox