[PATCH] [MTD] JFFS2: memory leak in jffs2_do_mount_fs()
Dmitry Adamushko
dmitry.adamushko at gmail.com
Mon Jan 22 10:27:30 EST 2007
[PATCH] [MTD] JFFS2: memory leak in jffs2_do_mount_fs()
If jffs2_sum_init() fails in jffs2_do_mount_fs(), c->blocks is not freed.
The patch addresses this issue.
Signed-off-by: Dmitry Adamushko <dmitry.adamushko at gmail dot com>
---
-- fs/jffs2/build.c 2006-12-17 21:29:07.000000000 +0100
+++ fs/jffs2/build-fix.c 2007-01-19 01:05:51.000000000 +0100
@@ -348,23 +348,27 @@ int jffs2_do_mount_fs(struct jffs2_sb_in
ret = jffs2_sum_init(c);
if (ret)
- return ret;
+ goto out_blocks;
if (jffs2_build_filesystem(c)) {
dbg_fsbuild("build_fs failed\n");
jffs2_free_ino_caches(c);
jffs2_free_raw_node_refs(c);
-#ifndef __ECOS
- if (jffs2_blocks_use_vmalloc(c))
- vfree(c->blocks);
- else
-#endif
- kfree(c->blocks);
- return -EIO;
+ ret = -EIO;
+ goto out_blocks;
}
jffs2_calc_trigger_levels(c);
return 0;
+
+ out_blocks:
+#ifndef __ECOS
+ if (jffs2_blocks_use_vmalloc(c))
+ vfree(c->blocks);
+ else
+#endif
+ kfree(c->blocks);
+ return ret;
}
More information about the linux-mtd
mailing list