summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Henriques (SUSE) <luis.henriques@linux.dev>2024-08-19 10:52:17 +0100
committerIlya Dryomov <idryomov@gmail.com>2024-09-24 22:51:33 +0200
commitd97079e97eab20e08afc507f2bed4501e2824717 (patch)
tree71c3778d10223c9c0a3cb2adda72cd25bcfa20b3
parentadc52461767f675264f2876d61e7220c113023e8 (diff)
downloadlwn-d97079e97eab20e08afc507f2bed4501e2824717.tar.gz
lwn-d97079e97eab20e08afc507f2bed4501e2824717.zip
ceph: fix a memory leak on cap_auths in MDS client
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) <luis.henriques@linux.dev> Reviewed-by: Xiubo Li <xiubli@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
-rw-r--r--fs/ceph/mds_client.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 9682c6ae3866..59eb13aabc81 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -6016,6 +6016,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);
}