Skip to content

Commit d97079e

Browse files
Luis Henriques (SUSE)idryomov
authored andcommitted
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: 1d17de9 ("ceph: save cap_auths in MDS client when session is opened") Signed-off-by: Luis Henriques (SUSE) <[email protected]> Reviewed-by: Xiubo Li <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent adc5246 commit d97079e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

fs/ceph/mds_client.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6016,6 +6016,18 @@ static void ceph_mdsc_stop(struct ceph_mds_client *mdsc)
60166016
ceph_mdsmap_destroy(mdsc->mdsmap);
60176017
kfree(mdsc->sessions);
60186018
ceph_caps_finalize(mdsc);
6019+
6020+
if (mdsc->s_cap_auths) {
6021+
int i;
6022+
6023+
for (i = 0; i < mdsc->s_cap_auths_num; i++) {
6024+
kfree(mdsc->s_cap_auths[i].match.gids);
6025+
kfree(mdsc->s_cap_auths[i].match.path);
6026+
kfree(mdsc->s_cap_auths[i].match.fs_name);
6027+
}
6028+
kfree(mdsc->s_cap_auths);
6029+
}
6030+
60196031
ceph_pool_perm_destroy(mdsc);
60206032
}
60216033

0 commit comments

Comments
 (0)