Skip to content

Commit 040d159

Browse files
MaxKellermannidryomov
authored andcommitted
ceph: fix memory leaks in ceph_mdsc_build_path()
Add __putname() calls to error code paths that did not free the "path" pointer obtained by __getname(). If ownership of this pointer is not passed to the caller via path_info.path, the function must free it before returning. Cc: [email protected] Fixes: 3fd945a ("ceph: encode encrypted name in ceph_mdsc_build_path and dentry release") Fixes: 550f7ca ("ceph: give up on paths longer than PATH_MAX") Signed-off-by: Max Kellermann <[email protected]> Reviewed-by: Viacheslav Dubeyko <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 43323a5 commit 040d159

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

fs/ceph/mds_client.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2768,6 +2768,7 @@ char *ceph_mdsc_build_path(struct ceph_mds_client *mdsc, struct dentry *dentry,
27682768
if (ret < 0) {
27692769
dput(parent);
27702770
dput(cur);
2771+
__putname(path);
27712772
return ERR_PTR(ret);
27722773
}
27732774

@@ -2777,6 +2778,7 @@ char *ceph_mdsc_build_path(struct ceph_mds_client *mdsc, struct dentry *dentry,
27772778
if (len < 0) {
27782779
dput(parent);
27792780
dput(cur);
2781+
__putname(path);
27802782
return ERR_PTR(len);
27812783
}
27822784
}
@@ -2813,6 +2815,7 @@ char *ceph_mdsc_build_path(struct ceph_mds_client *mdsc, struct dentry *dentry,
28132815
* cannot ever succeed. Creating paths that long is
28142816
* possible with Ceph, but Linux cannot use them.
28152817
*/
2818+
__putname(path);
28162819
return ERR_PTR(-ENAMETOOLONG);
28172820
}
28182821

0 commit comments

Comments
 (0)