Skip to content

Commit 3c1350d

Browse files
committed
smb3: fix problem unloading module due to leaked refcount on shutdown
JIRA: https://issues.redhat.com/browse/RHEL-57983 commit 15179cf Author: Steve French <stfrench@microsoft.com> Date: Fri Aug 16 16:47:39 2024 -0500 smb3: fix problem unloading module due to leaked refcount on shutdown The shutdown ioctl can leak a refcount on the tlink which can prevent rmmod (unloading the cifs.ko) module from working. Found while debugging xfstest generic/043 Fixes: 69ca1f5 ("smb3: add dynamic tracepoints for shutdown ioctl") Reviewed-by: Meetakshi Setiya <msetiya@microsoft.com> Reviewed-by: Shyam Prasad N <sprasad@microsoft.com> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Paulo Alcantara <paalcant@redhat.com>
1 parent bd9bb95 commit 3c1350d

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

fs/smb/client/connect.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4180,6 +4180,9 @@ tlink_rb_insert(struct rb_root *root, struct tcon_link *new_tlink)
41804180
*
41814181
* If one doesn't exist then insert a new tcon_link struct into the tree and
41824182
* try to construct a new one.
4183+
*
4184+
* REMEMBER to call cifs_put_tlink() after successful calls to cifs_sb_tlink,
4185+
* to avoid refcount issues
41834186
*/
41844187
struct tcon_link *
41854188
cifs_sb_tlink(struct cifs_sb_info *cifs_sb)

fs/smb/client/ioctl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,11 @@ static int cifs_shutdown(struct super_block *sb, unsigned long arg)
229229

230230
shutdown_good:
231231
trace_smb3_shutdown_done(flags, tcon->tid);
232+
cifs_put_tlink(tlink);
232233
return 0;
233234
shutdown_out_err:
234235
trace_smb3_shutdown_err(rc, flags, tcon->tid);
236+
cifs_put_tlink(tlink);
235237
return rc;
236238
}
237239

fs/smb/client/link.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ cifs_symlink(struct user_namespace *mnt_userns, struct inode *inode,
588588
tlink = cifs_sb_tlink(cifs_sb);
589589
if (IS_ERR(tlink)) {
590590
rc = PTR_ERR(tlink);
591+
/* BB could be clearer if skipped put_tlink on error here, but harmless */
591592
goto symlink_exit;
592593
}
593594
pTcon = tlink_tcon(tlink);

0 commit comments

Comments
 (0)