diff options
author | Zhao Hongjiang <zhaohongjiang@huawei.com> | 2013-08-20 16:49:51 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-08-20 18:58:44 +0900 |
commit | 9890ff3f23ed78c63611f661006cd5ae38550f44 (patch) | |
tree | a3c542503c09e8cdf65112a57572adbde638f688 /fs/f2fs/super.c | |
parent | 7b40527508670e56d817b837b2114bc340446539 (diff) | |
download | linux-9890ff3f23ed78c63611f661006cd5ae38550f44.tar.gz linux-9890ff3f23ed78c63611f661006cd5ae38550f44.tar.bz2 linux-9890ff3f23ed78c63611f661006cd5ae38550f44.zip |
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) goto fail; err = create_node_manager_caches(); if (err) - goto fail; + goto free_inodecache; err = create_gc_caches(); if (err) - goto fail; + goto free_node_manager_caches; err = create_checkpoint_caches(); if (err) - goto fail; + goto free_gc_caches; f2fs_kset = kset_create_and_add("f2fs", NULL, fs_kobj); if (!f2fs_kset) - goto fail; + goto free_checkpoint_caches; err = register_filesystem(&f2fs_fs_type); if (err) - goto fail; + goto free_kset; f2fs_create_root_stats(); f2fs_proc_root = proc_mkdir("fs/f2fs", NULL); + return 0; + +free_kset: + kset_unregister(f2fs_kset); +free_checkpoint_caches: + destroy_checkpoint_caches(); +free_gc_caches: + destroy_gc_caches(); +free_node_manager_caches: + destroy_node_manager_caches(); +free_inodecache: + destroy_inodecache(); fail: return err; } |