From: Luis Henriques (SUSE) Date: Mon, 19 Aug 2024 09:52:17 +0000 (+0100) Subject: ceph: fix a memory leak on cap_auths in MDS client X-Git-Tag: v6.10.14~468 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63104c3f527f51190b1839735bfc6d8f43f56cfa;p=thirdparty%2Fkernel%2Fstable.git ceph: fix a memory leak on cap_auths in MDS client [ Upstream commit d97079e97eab20e08afc507f2bed4501e2824717 ] The cap_auths that are allocated during an MDS session opening are never released, causing a memory leak detected by kmemleak. Fix this by freeing the memory allocated when shutting down the MDS client. Fixes: 1d17de9534cb ("ceph: save cap_auths in MDS client when session is opened") Signed-off-by: Luis Henriques (SUSE) Reviewed-by: Xiubo Li Signed-off-by: Ilya Dryomov Signed-off-by: Sasha Levin --- diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index c2157f6e0c698..d37e9ea571137 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -6011,6 +6011,18 @@ static void ceph_mdsc_stop(struct ceph_mds_client *mdsc) ceph_mdsmap_destroy(mdsc->mdsmap); kfree(mdsc->sessions); ceph_caps_finalize(mdsc); + + if (mdsc->s_cap_auths) { + int i; + + for (i = 0; i < mdsc->s_cap_auths_num; i++) { + kfree(mdsc->s_cap_auths[i].match.gids); + kfree(mdsc->s_cap_auths[i].match.path); + kfree(mdsc->s_cap_auths[i].match.fs_name); + } + kfree(mdsc->s_cap_auths); + } + ceph_pool_perm_destroy(mdsc); }