public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] jffs2: memory leak in jffs2_scan_medium()
@ 2006-05-15 15:54 Florin Malita
  2006-05-15 22:43 ` David Woodhouse
  0 siblings, 1 reply; 2+ messages in thread
From: Florin Malita @ 2006-05-15 15:54 UTC (permalink / raw)
  To: dwmw2; +Cc: linux-kernel

If jffs2_scan_eraseblock() fails and the exit path is taken, 's' is not
being deallocated.

Reported by Coverity, CID: 1258.

Signed-off-by: Florin Malita <fmalita@gmail.com>
---

diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index cf55b22..27a7021 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -222,9 +222,6 @@ #endif
 		}
 	}
 
-	if (jffs2_sum_active() && s)
-		kfree(s);
-
 	/* Nextblock dirty is always seen as wasted, because we cannot recycle it now */
 	if (c->nextblock && (c->nextblock->dirty_size)) {
 		c->nextblock->wasted_size += c->nextblock->dirty_size;
@@ -266,6 +263,8 @@ #ifndef __ECOS
 	else
 		c->mtd->unpoint(c->mtd, flashbuf, 0, c->mtd->size);
 #endif
+	kfree(s);
+	
 	return ret;
 }
 



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

* Re: [PATCH] jffs2: memory leak in jffs2_scan_medium()
  2006-05-15 15:54 [PATCH] jffs2: memory leak in jffs2_scan_medium() Florin Malita
@ 2006-05-15 22:43 ` David Woodhouse
  0 siblings, 0 replies; 2+ messages in thread
From: David Woodhouse @ 2006-05-15 22:43 UTC (permalink / raw)
  To: Florin Malita; +Cc: linux-kernel

On Mon, 2006-05-15 at 11:54 -0400, Florin Malita wrote:
> If jffs2_scan_eraseblock() fails and the exit path is taken, 's' is
> not
> being deallocated.
> 
> Reported by Coverity, CID: 1258.
> 
> Signed-off-by: Florin Malita <fmalita@gmail.com> 

Applied with minor modifications and no trailing whitespace; thanks.

-- 
dwmw2


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

end of thread, other threads:[~2006-05-15 22:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-15 15:54 [PATCH] jffs2: memory leak in jffs2_scan_medium() Florin Malita
2006-05-15 22:43 ` David Woodhouse

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