2006-05-15 15:56:51

by Florin Malita

[permalink] [raw]
Subject: [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 <[email protected]>
---

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




2006-05-15 22:43:24

by David Woodhouse

[permalink] [raw]
Subject: Re: [PATCH] jffs2: memory leak in jffs2_scan_medium()

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 <[email protected]>

Applied with minor modifications and no trailing whitespace; thanks.

--
dwmw2