Skip to content

Commit

Permalink
f2fs: fix memory leak after kobject init failed in fill_super
Browse files Browse the repository at this point in the history
If we failed to init&add kobject when fill_super, stats info and proc object of
f2fs will not be released.
We should free them before we finish fill_super.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
  • Loading branch information
Chao Yu authored and Jaegeuk Kim committed Nov 8, 2013
1 parent fb51b5e commit 1d15bd2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions fs/f2fs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -975,12 +975,12 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
/* After POR, we can run background GC thread.*/
err = start_gc_thread(sbi);
if (err)
goto fail;
goto free_gc;
}

err = f2fs_build_stats(sbi);
if (err)
goto fail;
goto free_gc;

if (f2fs_proc_root)
sbi->s_proc = proc_mkdir(sb->s_id, f2fs_proc_root);
Expand All @@ -1006,6 +1006,12 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)

return 0;
fail:
if (sbi->s_proc) {
remove_proc_entry("segment_info", sbi->s_proc);
remove_proc_entry(sb->s_id, f2fs_proc_root);
}
f2fs_destroy_stats(sbi);
free_gc:
stop_gc_thread(sbi);
free_root_inode:
dput(sb->s_root);
Expand Down

0 comments on commit 1d15bd2

Please sign in to comment.