From: Chengguang Xu Date: Thu, 1 Mar 2018 06:24:51 +0000 (+0800) Subject: ceph: fix potential memory leak in init_caches() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=07d3fb191b5a51af584e21e962fb796919d7db3f;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git ceph: fix potential memory leak in init_caches() [ Upstream commit 1c789249578895bb14ab62b4327306439b754857 ] There is lack of cache destroy operation for ceph_file_cachep when failing from fscache register. Signed-off-by: Chengguang Xu Reviewed-by: Ilya Dryomov Signed-off-by: Ilya Dryomov Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/ceph/super.c b/fs/ceph/super.c index 9c907e3aad26..48ffe720bf09 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -712,14 +712,17 @@ static int __init init_caches(void) goto bad_dentry; ceph_file_cachep = KMEM_CACHE(ceph_file_info, SLAB_MEM_SPREAD); - if (!ceph_file_cachep) goto bad_file; - if ((error = ceph_fscache_register())) - goto bad_file; + error = ceph_fscache_register(); + if (error) + goto bad_fscache; return 0; + +bad_fscache: + kmem_cache_destroy(ceph_file_cachep); bad_file: kmem_cache_destroy(ceph_dentry_cachep); bad_dentry: