diff options
| author | Chao Yu <chao2.yu@samsung.com> | 2013-11-06 21:14:51 -0500 |
|---|---|---|
| committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-11-08 00:10:29 -0500 |
| commit | 1d15bd2034c9b0f9ac88fa0e4cd33e0d792b0bb0 (patch) | |
| tree | 15ec30357bbfd5fe1af95e1f4a281b3dd3724d36 | |
| parent | fb51b5ef9c07844f80402702bd3d3002ceca5cd9 (diff) | |
f2fs: fix memory leak after kobject init failed in fill_super
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>
| -rw-r--r-- | fs/f2fs/super.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 00e79df5a34f..bafff72de8e8 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c | |||
| @@ -975,12 +975,12 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 975 | /* After POR, we can run background GC thread.*/ | 975 | /* After POR, we can run background GC thread.*/ |
| 976 | err = start_gc_thread(sbi); | 976 | err = start_gc_thread(sbi); |
| 977 | if (err) | 977 | if (err) |
| 978 | goto fail; | 978 | goto free_gc; |
| 979 | } | 979 | } |
| 980 | 980 | ||
| 981 | err = f2fs_build_stats(sbi); | 981 | err = f2fs_build_stats(sbi); |
| 982 | if (err) | 982 | if (err) |
| 983 | goto fail; | 983 | goto free_gc; |
| 984 | 984 | ||
| 985 | if (f2fs_proc_root) | 985 | if (f2fs_proc_root) |
| 986 | sbi->s_proc = proc_mkdir(sb->s_id, f2fs_proc_root); | 986 | sbi->s_proc = proc_mkdir(sb->s_id, f2fs_proc_root); |
| @@ -1006,6 +1006,12 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 1006 | 1006 | ||
| 1007 | return 0; | 1007 | return 0; |
| 1008 | fail: | 1008 | fail: |
| 1009 | if (sbi->s_proc) { | ||
| 1010 | remove_proc_entry("segment_info", sbi->s_proc); | ||
| 1011 | remove_proc_entry(sb->s_id, f2fs_proc_root); | ||
| 1012 | } | ||
| 1013 | f2fs_destroy_stats(sbi); | ||
| 1014 | free_gc: | ||
| 1009 | stop_gc_thread(sbi); | 1015 | stop_gc_thread(sbi); |
| 1010 | free_root_inode: | 1016 | free_root_inode: |
| 1011 | dput(sb->s_root); | 1017 | dput(sb->s_root); |
