Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 56c762eb9bee ("cifs: Refactor out cifs_mount()")
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Zhang Xiaoxu and committed by
Steve French
1dcdf5f5 f0c4d9fc

+11 -3
+11 -3
fs/cifs/connect.c
··· 3855 3855 uuid_copy(&cifs_sb->dfs_mount_id, &mnt_ctx.mount_id); 3856 3856 3857 3857 out: 3858 - free_xid(mnt_ctx.xid); 3859 3858 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; 3861 3865 3862 3866 error: 3863 3867 dfs_cache_put_refsrv_sessions(&mnt_ctx.mount_id); ··· 3888 3884 goto error; 3889 3885 } 3890 3886 3887 + rc = mount_setup_tlink(cifs_sb, mnt_ctx.ses, mnt_ctx.tcon); 3888 + if (rc) 3889 + goto error; 3890 + 3891 3891 free_xid(mnt_ctx.xid); 3892 - return mount_setup_tlink(cifs_sb, mnt_ctx.ses, mnt_ctx.tcon); 3892 + return rc; 3893 3893 3894 3894 error: 3895 3895 mount_put_conns(&mnt_ctx);