]> err.no Git - linux-2.6/commitdiff
JFFS2: memory leak in jffs2_do_mount_fs()
authorDmitry Adamushko <dmitry.adamushko@gmail.com>
Fri, 19 Jan 2007 00:20:30 +0000 (01:20 +0100)
committerDavid Woodhouse <dwmw2@infradead.org>
Fri, 9 Feb 2007 15:00:21 +0000 (15:00 +0000)
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@gmail.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
fs/jffs2/build.c

index 02826967ab58918ac6fa6ec7723d5e81485c357e..07119c42a861ad2ddf6fa86ae7fc79753879aa0f 100644 (file)
@@ -348,23 +348,27 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c)
 
        ret = jffs2_sum_init(c);
        if (ret)
-               return ret;
+               goto out_free;
 
        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_free;
        }
 
        jffs2_calc_trigger_levels(c);
 
        return 0;
+
+ out_free:
+#ifndef __ECOS
+       if (jffs2_blocks_use_vmalloc(c))
+               vfree(c->blocks);
+       else
+#endif
+               kfree(c->blocks);
+
+       return ret;
 }