Skip to content

Commit c2b77f4

Browse files
sfu2smfrench
authored andcommitted
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: [email protected] Signed-off-by: Shuhao Fu <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent d451a0e commit c2b77f4

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

fs/smb/client/inode.c

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

2434-
if (!server->ops->rename)
2435-
return -ENOSYS;
2434+
if (!server->ops->rename) {
2435+
rc = -ENOSYS;
2436+
goto do_rename_exit;
2437+
}
24362438

24372439
/* try path-based rename first */
24382440
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
@@ -3212,8 +3212,7 @@ get_smb2_acl_by_path(struct cifs_sb_info *cifs_sb,
32123212
utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
32133213
if (!utf16_path) {
32143214
rc = -ENOMEM;
3215-
free_xid(xid);
3216-
return ERR_PTR(rc);
3215+
goto put_tlink;
32173216
}
32183217

32193218
oparms = (struct cifs_open_parms) {
@@ -3245,6 +3244,7 @@ get_smb2_acl_by_path(struct cifs_sb_info *cifs_sb,
32453244
SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
32463245
}
32473246

3247+
put_tlink:
32483248
cifs_put_tlink(tlink);
32493249
free_xid(xid);
32503250

@@ -3285,8 +3285,7 @@ set_smb2_acl(struct smb_ntsd *pnntsd, __u32 acllen,
32853285
utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
32863286
if (!utf16_path) {
32873287
rc = -ENOMEM;
3288-
free_xid(xid);
3289-
return rc;
3288+
goto put_tlink;
32903289
}
32913290

32923291
oparms = (struct cifs_open_parms) {
@@ -3307,6 +3306,7 @@ set_smb2_acl(struct smb_ntsd *pnntsd, __u32 acllen,
33073306
SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
33083307
}
33093308

3309+
put_tlink:
33103310
cifs_put_tlink(tlink);
33113311
free_xid(xid);
33123312
return rc;

0 commit comments

Comments
 (0)