Skip to content

Commit b540de9

Browse files
sfu2smfrench
authored andcommitted
smb: client: fix refcount leak in smb2_set_path_attr
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: 8de9e86 ("cifs: create a helper to find a writeable handle by path name") Acked-by: Henrique Carvalho <[email protected]> Signed-off-by: Shuhao Fu <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 734e996 commit b540de9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/smb/client/smb2inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,8 @@ static int smb2_set_path_attr(const unsigned int xid, struct cifs_tcon *tcon,
12941294
smb2_to_name = cifs_convert_path_to_utf16(to_name, cifs_sb);
12951295
if (smb2_to_name == NULL) {
12961296
rc = -ENOMEM;
1297+
if (cfile)
1298+
cifsFileInfo_put(cfile);
12971299
goto smb2_rename_path;
12981300
}
12991301
in_iov.iov_base = smb2_to_name;

0 commit comments

Comments
 (0)