aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDmitry Adamushko <dmitry.adamushko@gmail.com>2007-01-18 19:20:30 -0500
committerDavid Woodhouse <dwmw2@infradead.org>2007-02-09 10:00:21 -0500
commitcfa72397cf3a15f2841447440fd53980b3ecd624 (patch)
treed6e3dd264f523845e0c0fb05da377485c3bc40e6 /fs
parent0d36da3b409536a24266c5f0972f2e1cfae1afd4 (diff)
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@gmail.com> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/jffs2/build.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/fs/jffs2/build.c b/fs/jffs2/build.c
index 02826967ab58..07119c42a861 100644
--- a/fs/jffs2/build.c
+++ b/fs/jffs2/build.c
@@ -348,23 +348,27 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c)
348 348
349 ret = jffs2_sum_init(c); 349 ret = jffs2_sum_init(c);
350 if (ret) 350 if (ret)
351 return ret; 351 goto out_free;
352 352
353 if (jffs2_build_filesystem(c)) { 353 if (jffs2_build_filesystem(c)) {
354 dbg_fsbuild("build_fs failed\n"); 354 dbg_fsbuild("build_fs failed\n");
355 jffs2_free_ino_caches(c); 355 jffs2_free_ino_caches(c);
356 jffs2_free_raw_node_refs(c); 356 jffs2_free_raw_node_refs(c);
357#ifndef __ECOS 357 ret = -EIO;
358 if (jffs2_blocks_use_vmalloc(c)) 358 goto out_free;
359 vfree(c->blocks);
360 else
361#endif
362 kfree(c->blocks);
363
364 return -EIO;
365 } 359 }
366 360
367 jffs2_calc_trigger_levels(c); 361 jffs2_calc_trigger_levels(c);
368 362
369 return 0; 363 return 0;
364
365 out_free:
366#ifndef __ECOS
367 if (jffs2_blocks_use_vmalloc(c))
368 vfree(c->blocks);
369 else
370#endif
371 kfree(c->blocks);
372
373 return ret;
370} 374}