Commit 5b5ffbc1 authored by Florin Malita's avatar Florin Malita Committed by David Woodhouse

[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: default avatarFlorin Malita <fmalita@gmail.com>
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent 184f5652
...@@ -222,9 +222,6 @@ int jffs2_scan_medium(struct jffs2_sb_info *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 */ /* Nextblock dirty is always seen as wasted, because we cannot recycle it now */
if (c->nextblock && (c->nextblock->dirty_size)) { if (c->nextblock && (c->nextblock->dirty_size)) {
c->nextblock->wasted_size += 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) ...@@ -266,6 +263,9 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
else else
c->mtd->unpoint(c->mtd, flashbuf, 0, c->mtd->size); c->mtd->unpoint(c->mtd, flashbuf, 0, c->mtd->size);
#endif #endif
if (s)
kfree(s);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment