aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2006-05-20 20:28:05 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2006-05-20 20:28:05 -0400
commit3560160aa26ebced1944aaa2e7e436d2a1b1bf70 (patch)
treeee0bb33931cef644b1e5f6794e6bed833f33d42c /fs
parent6171586a7ae5198988774e8480631e8d15f65dfe (diff)
[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: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/jffs2/scan.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index 06637050749d..192b0bd21180 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -516,10 +516,15 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
516 516
517 if (sumptr) { 517 if (sumptr) {
518 err = jffs2_sum_scan_sumnode(c, jeb, sumptr, sumlen, &pseudo_random); 518 err = jffs2_sum_scan_sumnode(c, jeb, sumptr, sumlen, &pseudo_random);
519 if (err) 519
520 return err;
521 if (buf_size && sumlen > buf_size) 520 if (buf_size && sumlen > buf_size)
522 kfree(sumptr); 521 kfree(sumptr);
522 /* If it returns with a real error, bail.
523 If it returns positive, that's a block classification
524 (i.e. BLK_STATE_xxx) so return that too.
525 If it returns zero, fall through to full scan. */
526 if (err)
527 return err;
523 } 528 }
524 } 529 }
525 530