Skip to content

Commit 4d1411a

Browse files
committed
smb: client: Fix refcount leak for cifs_sb_tlink
JIRA: https://issues.redhat.com/browse/RHEL-114699 commit c2b77f4 Author: Shuhao Fu <sfual@cse.ust.hk> Date: Thu Oct 16 02:52:55 2025 +0000 smb: client: Fix refcount leak for cifs_sb_tlink Fix three refcount inconsistency issues related to `cifs_sb_tlink`. Comments for `cifs_sb_tlink` state that `cifs_put_tlink()` needs to be called after successful calls to `cifs_sb_tlink()`. Three calls fail to update refcount accordingly, leading to possible resource leaks. Fixes: 8ceb984 ("CIFS: Move rename to ops struct") Fixes: 2f1afe2 ("cifs: Use smb 2 - 3 and cifsacl mount options getacl functions") Fixes: 366ed84 ("cifs: Use smb 2 - 3 and cifsacl mount options setacl function") Cc: stable@vger.kernel.org Signed-off-by: Shuhao Fu <sfual@cse.ust.hk> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Paulo Alcantara <paalcant@redhat.com>
1 parent 45abc0e commit 4d1411a

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

fs/smb/client/inode.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2411,8 +2411,10 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry,
24112411
tcon = tlink_tcon(tlink);
24122412
server = tcon->ses->server;
24132413

2414-
if (!server->ops->rename)
2415-
return -ENOSYS;
2414+
if (!server->ops->rename) {
2415+
rc = -ENOSYS;
2416+
goto do_rename_exit;
2417+
}
24162418

24172419
/* try path-based rename first */
24182420
rc = server->ops->rename(xid, tcon, from_dentry,

fs/smb/client/smb2ops.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3082,8 +3082,7 @@ get_smb2_acl_by_path(struct cifs_sb_info *cifs_sb,
30823082
utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
30833083
if (!utf16_path) {
30843084
rc = -ENOMEM;
3085-
free_xid(xid);
3086-
return ERR_PTR(rc);
3085+
goto put_tlink;
30873086
}
30883087

30893088
oparms = (struct cifs_open_parms) {
@@ -3115,6 +3114,7 @@ get_smb2_acl_by_path(struct cifs_sb_info *cifs_sb,
31153114
SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
31163115
}
31173116

3117+
put_tlink:
31183118
cifs_put_tlink(tlink);
31193119
free_xid(xid);
31203120

@@ -3155,8 +3155,7 @@ set_smb2_acl(struct smb_ntsd *pnntsd, __u32 acllen,
31553155
utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
31563156
if (!utf16_path) {
31573157
rc = -ENOMEM;
3158-
free_xid(xid);
3159-
return rc;
3158+
goto put_tlink;
31603159
}
31613160

31623161
oparms = (struct cifs_open_parms) {
@@ -3177,6 +3176,7 @@ set_smb2_acl(struct smb_ntsd *pnntsd, __u32 acllen,
31773176
SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
31783177
}
31793178

3179+
put_tlink:
31803180
cifs_put_tlink(tlink);
31813181
free_xid(xid);
31823182
return rc;

0 commit comments

Comments
 (0)