mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Memory leak in mtd/chips/cfi_cmdset_0020.c
@ 2003-09-23 19:25 Felipe W Damasio
  2003-09-23 20:34 ` Andrew Morton
  2003-09-23 20:37 ` Jörn Engel
  0 siblings, 2 replies; 3+ messages in thread
From: Felipe W Damasio @ 2003-09-23 19:25 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linux Kernel Mailing List

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

	Hi Andrew,

	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.

	Found by the Stanford Checker.

	Thanks,

Felipe

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

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

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

* Re: [PATCH] Memory leak in mtd/chips/cfi_cmdset_0020.c
  2003-09-23 19:25 [PATCH] Memory leak in mtd/chips/cfi_cmdset_0020.c Felipe W Damasio
@ 2003-09-23 20:34 ` Andrew Morton
  2003-09-23 20:37 ` Jörn Engel
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2003-09-23 20:34 UTC (permalink / raw)
  To: Felipe W Damasio; +Cc: linux-kernel

Felipe W Damasio <felipewd@terra.com.br> wrote:
>
> 	This function is called by inter_module_register...so I'm not sure it 
> should really be freed...please review :)

Is fine, thanks.

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

* Re: [PATCH] Memory leak in mtd/chips/cfi_cmdset_0020.c
  2003-09-23 19:25 [PATCH] Memory leak in mtd/chips/cfi_cmdset_0020.c Felipe W Damasio
  2003-09-23 20:34 ` Andrew Morton
@ 2003-09-23 20:37 ` Jörn Engel
  1 sibling, 0 replies; 3+ messages in thread
From: Jörn Engel @ 2003-09-23 20:37 UTC (permalink / raw)
  To: Felipe W Damasio
  Cc: Andrew Morton, Linux Kernel Mailing List, David Woodhouse, linux-mtd

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

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

end of thread, other threads:[~2003-09-23 20:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-23 19:25 [PATCH] Memory leak in mtd/chips/cfi_cmdset_0020.c Felipe W Damasio
2003-09-23 20:34 ` Andrew Morton
2003-09-23 20:37 ` Jörn Engel

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

all inboxes | Powered by JetHome®