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

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sun May 21 14:59:10 EDT 2006

Commit:     3560160aa26ebced1944aaa2e7e436d2a1b1bf70
Parent:     6171586a7ae5198988774e8480631e8d15f65dfe
Author:     David Woodhouse <dwmw2 at infradead.org>
AuthorDate: Sun May 21 01:28:05 2006 +0100
Commit:     David Woodhouse <dwmw2 at infradead.org>
CommitDate: Sun May 21 01:28:05 2006 +0100

    [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 at infradead.org>

 fs/jffs2/scan.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index 0663705..192b0bd 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -516,10 +516,15 @@ #endif
 		if (sumptr) {
 			err = jffs2_sum_scan_sumnode(c, jeb, sumptr, sumlen, &pseudo_random);
-			if (err)
-				return err;
 			if (buf_size && sumlen > buf_size)
+			/* 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;

More information about the linux-mtd-cvs mailing list