Commit 1c789249 authored by Chengguang Xu's avatar Chengguang Xu Committed by Ilya Dryomov

ceph: fix potential memory leak in init_caches()

There is lack of cache destroy operation for ceph_file_cachep
when failing from fscache register.
Signed-off-by: default avatarChengguang Xu <cgxu519@icloud.com>
Reviewed-by: default avatarIlya Dryomov <idryomov@gmail.com>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent 18106734
...@@ -713,14 +713,17 @@ static int __init init_caches(void) ...@@ -713,14 +713,17 @@ static int __init init_caches(void)
goto bad_dentry; goto bad_dentry;
ceph_file_cachep = KMEM_CACHE(ceph_file_info, SLAB_MEM_SPREAD); ceph_file_cachep = KMEM_CACHE(ceph_file_info, SLAB_MEM_SPREAD);
if (!ceph_file_cachep) if (!ceph_file_cachep)
goto bad_file; goto bad_file;
if ((error = ceph_fscache_register())) error = ceph_fscache_register();
goto bad_file; if (error)
goto bad_fscache;
return 0; return 0;
bad_fscache:
kmem_cache_destroy(ceph_file_cachep);
bad_file: bad_file:
kmem_cache_destroy(ceph_dentry_cachep); kmem_cache_destroy(ceph_dentry_cachep);
bad_dentry: bad_dentry:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment