Skip to content

Commit 91f4480

Browse files
sprasad-microsoftsmfrench
authored andcommitted
cifs: fix status checks in cifs_tree_connect
The ordering of status checks at the beginning of cifs_tree_connect is wrong. As a result, a tcon which is good may stay marked as needing reconnect infinitely. Fixes: 2f0e4f0 ("cifs: check only tcon status on tcon related functions") Cc: stable@vger.kernel.org # 6.3 Signed-off-by: Shyam Prasad N <sprasad@microsoft.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent a5998a9 commit 91f4480

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

fs/smb/client/connect.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4086,16 +4086,17 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
40864086

40874087
/* only send once per connect */
40884088
spin_lock(&tcon->tc_lock);
4089+
if (tcon->status == TID_GOOD) {
4090+
spin_unlock(&tcon->tc_lock);
4091+
return 0;
4092+
}
4093+
40894094
if (tcon->status != TID_NEW &&
40904095
tcon->status != TID_NEED_TCON) {
40914096
spin_unlock(&tcon->tc_lock);
40924097
return -EHOSTDOWN;
40934098
}
40944099

4095-
if (tcon->status == TID_GOOD) {
4096-
spin_unlock(&tcon->tc_lock);
4097-
return 0;
4098-
}
40994100
tcon->status = TID_IN_TCON;
41004101
spin_unlock(&tcon->tc_lock);
41014102

fs/smb/client/dfs.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -575,16 +575,17 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
575575

576576
/* only send once per connect */
577577
spin_lock(&tcon->tc_lock);
578+
if (tcon->status == TID_GOOD) {
579+
spin_unlock(&tcon->tc_lock);
580+
return 0;
581+
}
582+
578583
if (tcon->status != TID_NEW &&
579584
tcon->status != TID_NEED_TCON) {
580585
spin_unlock(&tcon->tc_lock);
581586
return -EHOSTDOWN;
582587
}
583588

584-
if (tcon->status == TID_GOOD) {
585-
spin_unlock(&tcon->tc_lock);
586-
return 0;
587-
}
588589
tcon->status = TID_IN_TCON;
589590
spin_unlock(&tcon->tc_lock);
590591

0 commit comments

Comments
 (0)