Skip to content

Commit 1dcdf5f

Browse files
z00467499smfrench
authored andcommitted
cifs: Fix connections leak when tlink setup failed
If the tlink setup failed, lost to put the connections, then the module refcnt leak since the cifsd kthread not exit. Also leak the fscache info, and for next mount with fsc, it will print the follow errors: CIFS: Cache volume key already in use (cifs,127.0.0.1:445,TEST) Let's check the result of tlink setup, and do some cleanup. Fixes: 56c762e ("cifs: Refactor out cifs_mount()") Reviewed-by: Paulo Alcantara (SUSE) <[email protected]> Signed-off-by: Zhang Xiaoxu <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent f0c4d9f commit 1dcdf5f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

fs/cifs/connect.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3855,9 +3855,13 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
38553855
uuid_copy(&cifs_sb->dfs_mount_id, &mnt_ctx.mount_id);
38563856

38573857
out:
3858-
free_xid(mnt_ctx.xid);
38593858
cifs_try_adding_channels(cifs_sb, mnt_ctx.ses);
3860-
return mount_setup_tlink(cifs_sb, mnt_ctx.ses, mnt_ctx.tcon);
3859+
rc = mount_setup_tlink(cifs_sb, mnt_ctx.ses, mnt_ctx.tcon);
3860+
if (rc)
3861+
goto error;
3862+
3863+
free_xid(mnt_ctx.xid);
3864+
return rc;
38613865

38623866
error:
38633867
dfs_cache_put_refsrv_sessions(&mnt_ctx.mount_id);
@@ -3884,8 +3888,12 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
38843888
goto error;
38853889
}
38863890

3891+
rc = mount_setup_tlink(cifs_sb, mnt_ctx.ses, mnt_ctx.tcon);
3892+
if (rc)
3893+
goto error;
3894+
38873895
free_xid(mnt_ctx.xid);
3888-
return mount_setup_tlink(cifs_sb, mnt_ctx.ses, mnt_ctx.tcon);
3896+
return rc;
38893897

38903898
error:
38913899
mount_put_conns(&mnt_ctx);

0 commit comments

Comments
 (0)