Skip to content

Commit 15179cf

Browse files
committed
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 <[email protected]> Reviewed-by: Shyam Prasad N <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent e4be320 commit 15179cf

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
@@ -4194,6 +4194,9 @@ tlink_rb_insert(struct rb_root *root, struct tcon_link *new_tlink)
41944194
*
41954195
* If one doesn't exist then insert a new tcon_link struct into the tree and
41964196
* try to construct a new one.
4197+
*
4198+
* REMEMBER to call cifs_put_tlink() after successful calls to cifs_sb_tlink,
4199+
* to avoid refcount issues
41974200
*/
41984201
struct tcon_link *
41994202
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 mnt_idmap *idmap, 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)