ceph: fix memory in MDS client cap_auths
PATCH v2 1/1 ceph: fix memory in MDS client cap_auths
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.
---
Changes since v1:
* dropped mdsc->mutex locking as we don't need it at this point
fs/ceph/mds_client.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
fs/ceph/mds_client.c +12 -0
@@ -6015,6 +6015,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); }
Quoted 26 lines · Luis Henriques (SUSE)
The
cap_authsthat 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) <[email protected]>---
Changes since v1:
* droppedmdsc->mutexlocking as we don't need it at this pointfs/ceph/mds_client.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)fs/ceph/mds_client.c +5
-0@@ -6015,6 +6015,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++) {
fs/ceph/mds_client.c static void ceph_mdsc_stop(struct ceph_mds_client *mdsc) · line 6032
Quoted 10 lines
fs/ceph/mds_client.c +7
-0+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); }
LGTM.
Will apply to the testing branch and run the tests.
Thanks Luis
- Xiubo