[PATCH] [MTD] JFFS2: memory leak in jffs2_do_mount_fs()

Dmitry Adamushko dmitry.adamushko at gmail.com
Thu Jan 18 19:20:30 EST 2007


[PATCH] [MTD] JFFS2: memory leak in jffs2_do_mount_fs()

If  jffs2_sum_init()  fails,  c->blocks is not freed neither in
jffs2_do_mount_fs() nor in jffs2_do_fill_super().

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