Skip to content

Commit 5bff9f7

Browse files
Paulo AlcantaraSteve French
authored andcommitted
cifs: protect session status check in smb2_reconnect()
Use @ses->ses_lock to protect access of @ses->ses_status. Cc: stable@vger.kernel.org Signed-off-by: Paulo Alcantara (SUSE) <pc@manguebit.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 3d6b15a commit 5bff9f7

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

fs/cifs/smb2pdu.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,17 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
175175
}
176176
}
177177
spin_unlock(&tcon->tc_lock);
178-
if ((!tcon->ses) || (tcon->ses->ses_status == SES_EXITING) ||
179-
(!tcon->ses->server) || !server)
178+
179+
ses = tcon->ses;
180+
if (!ses)
181+
return -EIO;
182+
spin_lock(&ses->ses_lock);
183+
if (ses->ses_status == SES_EXITING) {
184+
spin_unlock(&ses->ses_lock);
185+
return -EIO;
186+
}
187+
spin_unlock(&ses->ses_lock);
188+
if (!ses->server || !server)
180189
return -EIO;
181190

182191
spin_lock(&server->srv_lock);
@@ -204,8 +213,6 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
204213
if (rc)
205214
return rc;
206215

207-
ses = tcon->ses;
208-
209216
spin_lock(&ses->chan_lock);
210217
if (!cifs_chan_needs_reconnect(ses, server) && !tcon->need_reconnect) {
211218
spin_unlock(&ses->chan_lock);

0 commit comments

Comments
 (0)