Skip to contentSkip to conversation

jffs2: memory leak in jffs2_scan_medium()

PATCH In review Florin Malita 2 participants 2 messages May 15, 2006 Journalling flash file system V2 (JFFS2)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---

fs/jffs2/scan.c +2 -3
index cf55b22..27a7021 100644
@@ -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;
 }
 
maintainer
#1 lore raw
Quoted 7 lines · Florin Malita

If jffs2_scan_eraseblock() fails and the exit path is taken, 's' is not
being deallocated.

Reported by Coverity, CID: 1258.

Applied with minor modifications and no trailing whitespace; thanks.

Signature · 1 line
dwmw2