diff options
author | Zhao Hongjiang <zhaohongjiang@huawei.com> | 2013-08-20 04:49:51 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-08-20 05:58:44 -0400 |
commit | 9890ff3f23ed78c63611f661006cd5ae38550f44 (patch) | |
tree | a3c542503c09e8cdf65112a57572adbde638f688 /fs/f2fs/super.c | |
parent | 7b40527508670e56d817b837b2114bc340446539 (diff) |
f2fs: fix memory leak when init f2fs filesystem fail
When any of the caches create fails in init_f2fs_fs(), the other caches which are
create successful should be free.
Signed-off-by: Zhao Hongjiang <zhaohongjiang@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs/super.c')
-rw-r--r-- | fs/f2fs/super.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 1d12e60c00d9..9e51e4fc00a0 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c | |||
@@ -1004,21 +1004,33 @@ static int __init init_f2fs_fs(void) | |||
1004 | goto fail; | 1004 | goto fail; |
1005 | err = create_node_manager_caches(); | 1005 | err = create_node_manager_caches(); |
1006 | if (err) | 1006 | if (err) |
1007 | goto fail; | 1007 | goto free_inodecache; |
1008 | err = create_gc_caches(); | 1008 | err = create_gc_caches(); |
1009 | if (err) | 1009 | if (err) |
1010 | goto fail; | 1010 | goto free_node_manager_caches; |
1011 | err = create_checkpoint_caches(); | 1011 | err = create_checkpoint_caches(); |
1012 | if (err) | 1012 | if (err) |
1013 | goto fail; | 1013 | goto free_gc_caches; |
1014 | f2fs_kset = kset_create_and_add("f2fs", NULL, fs_kobj); | 1014 | f2fs_kset = kset_create_and_add("f2fs", NULL, fs_kobj); |
1015 | if (!f2fs_kset) | 1015 | if (!f2fs_kset) |
1016 | goto fail; | 1016 | goto free_checkpoint_caches; |
1017 | err = register_filesystem(&f2fs_fs_type); | 1017 | err = register_filesystem(&f2fs_fs_type); |
1018 | if (err) | 1018 | if (err) |
1019 | goto fail; | 1019 | goto free_kset; |
1020 | f2fs_create_root_stats(); | 1020 | f2fs_create_root_stats(); |
1021 | f2fs_proc_root = proc_mkdir("fs/f2fs", NULL); | 1021 | f2fs_proc_root = proc_mkdir("fs/f2fs", NULL); |
1022 | return 0; | ||
1023 | |||
1024 | free_kset: | ||
1025 | kset_unregister(f2fs_kset); | ||
1026 | free_checkpoint_caches: | ||
1027 | destroy_checkpoint_caches(); | ||
1028 | free_gc_caches: | ||
1029 | destroy_gc_caches(); | ||
1030 | free_node_manager_caches: | ||
1031 | destroy_node_manager_caches(); | ||
1032 | free_inodecache: | ||
1033 | destroy_inodecache(); | ||
1022 | fail: | 1034 | fail: |
1023 | return err; | 1035 | return err; |
1024 | } | 1036 | } |