From: Florin Malita Date: Mon, 15 May 2006 22:42:31 +0000 (+0100) Subject: [PATCH] jffs2: memory leak in jffs2_scan_medium() X-Git-Tag: v2.6.18-rc1~1105^2~104 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=5b5ffbc1e6d62d89747f3f59c09b2e488a7d7fce;p=linux-2.6-omap-h63xx.git [PATCH] jffs2: memory leak in jffs2_scan_medium() 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 Signed-off-by: David Woodhouse --- diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c index cf55b221fc2..eca0996def6 100644 --- a/fs/jffs2/scan.c +++ b/fs/jffs2/scan.c @@ -222,9 +222,6 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) } } - 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,9 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) else c->mtd->unpoint(c->mtd, flashbuf, 0, c->mtd->size); #endif + if (s) + kfree(s); + return ret; }