Commit cfa72397 authored by Dmitry Adamushko's avatar Dmitry Adamushko Committed by David Woodhouse

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: default avatarDmitry Adamushko <dmitry.adamushko@gmail.com>
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent 0d36da3b
...@@ -348,12 +348,21 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c) ...@@ -348,12 +348,21 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c)
ret = jffs2_sum_init(c); ret = jffs2_sum_init(c);
if (ret) if (ret)
return ret; goto out_free;
if (jffs2_build_filesystem(c)) { if (jffs2_build_filesystem(c)) {
dbg_fsbuild("build_fs failed\n"); dbg_fsbuild("build_fs failed\n");
jffs2_free_ino_caches(c); jffs2_free_ino_caches(c);
jffs2_free_raw_node_refs(c); jffs2_free_raw_node_refs(c);
ret = -EIO;
goto out_free;
}
jffs2_calc_trigger_levels(c);
return 0;
out_free:
#ifndef __ECOS #ifndef __ECOS
if (jffs2_blocks_use_vmalloc(c)) if (jffs2_blocks_use_vmalloc(c))
vfree(c->blocks); vfree(c->blocks);
...@@ -361,10 +370,5 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c) ...@@ -361,10 +370,5 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c)
#endif #endif
kfree(c->blocks); kfree(c->blocks);
return -EIO; return ret;
}
jffs2_calc_trigger_levels(c);
return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment