提交 3560160a 编写于 作者: D David Woodhouse

[JFFS2] Fix memory leak in scan code; improve comments.

If we had to allocate extra space for the summary node, we weren't
correctly freeing it when jffs2_sum_scan_sumnode() returned nonzero --
which is both the success and the failure case. Only when it returned
zero, which means fall through to the full scan, were we correctly freeing
the buffer.

Document the meaning of those return codes while we're at it.
Signed-off-by: NDavid Woodhouse <dwmw2@infradead.org>
上级 6171586a
...@@ -516,10 +516,15 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -516,10 +516,15 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
if (sumptr) { if (sumptr) {
err = jffs2_sum_scan_sumnode(c, jeb, sumptr, sumlen, &pseudo_random); err = jffs2_sum_scan_sumnode(c, jeb, sumptr, sumlen, &pseudo_random);
if (err)
return err;
if (buf_size && sumlen > buf_size) if (buf_size && sumlen > buf_size)
kfree(sumptr); kfree(sumptr);
/* If it returns with a real error, bail.
If it returns positive, that's a block classification
(i.e. BLK_STATE_xxx) so return that too.
If it returns zero, fall through to full scan. */
if (err)
return err;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册