summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorShuhao Fu <sfual@cse.ust.hk>2025-11-04 23:13:15 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-11-24 10:29:56 +0100
commitd6ab7ef52aafc9af76ac22b34143ac13a3fb19a3 (patch)
tree80058469707785c09cbf0ad495b2495e69e0f85e /fs
parentc63dc33e3794163e98214ca0c2a7b6b1569126de (diff)
downloadlinux-d6ab7ef52aafc9af76ac22b34143ac13a3fb19a3.tar.gz
linux-d6ab7ef52aafc9af76ac22b34143ac13a3fb19a3.tar.bz2
linux-d6ab7ef52aafc9af76ac22b34143ac13a3fb19a3.zip
smb: client: fix refcount leak in smb2_set_path_attr
[ Upstream commit b540de9e3b4fab3b9e10f30714a6f5c1b2a50ec3 ] Fix refcount leak in `smb2_set_path_attr` when path conversion fails. Function `cifs_get_writable_path` returns `cfile` with its reference counter `cfile->count` increased on success. Function `smb2_compound_op` would decrease the reference counter for `cfile`, as stated in its comment. By calling `smb2_rename_path`, the reference counter of `cfile` would leak if `cifs_convert_path_to_utf16` fails in `smb2_set_path_attr`. Fixes: 8de9e86c67ba ("cifs: create a helper to find a writeable handle by path name") Acked-by: Henrique Carvalho <henrique.carvalho@suse.com> Signed-off-by: Shuhao Fu <sfual@cse.ust.hk> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/smb/client/smb2inode.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/smb/client/smb2inode.c b/fs/smb/client/smb2inode.c
index 232a3c289055..d6086394d0b8 100644
--- a/fs/smb/client/smb2inode.c
+++ b/fs/smb/client/smb2inode.c
@@ -1128,6 +1128,8 @@ static int smb2_set_path_attr(const unsigned int xid, struct cifs_tcon *tcon,
smb2_to_name = cifs_convert_path_to_utf16(to_name, cifs_sb);
if (smb2_to_name == NULL) {
rc = -ENOMEM;
+ if (cfile)
+ cifsFileInfo_put(cfile);
goto smb2_rename_path;
}
in_iov.iov_base = smb2_to_name;