Skip to content

Commit 943fb67

Browse files
committed
cifs: missing lock when updating session status
Coverity noted a place where we were not grabbing the ses_lock when setting (and checking) ses_status. Addresses-Coverity: 1536833 ("Data race condition (MISSING_LOCK)") Reviewed-by: Paulo Alcantara (SUSE) <[email protected]> Reviewed-by: Bharath SM <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent d906be3 commit 943fb67

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/cifs/connect.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,18 +1916,22 @@ void cifs_put_smb_ses(struct cifs_ses *ses)
19161916
/* ses_count can never go negative */
19171917
WARN_ON(ses->ses_count < 0);
19181918

1919+
spin_lock(&ses->ses_lock);
19191920
if (ses->ses_status == SES_GOOD)
19201921
ses->ses_status = SES_EXITING;
19211922

1922-
cifs_free_ipc(ses);
1923-
19241923
if (ses->ses_status == SES_EXITING && server->ops->logoff) {
1924+
spin_unlock(&ses->ses_lock);
1925+
cifs_free_ipc(ses);
19251926
xid = get_xid();
19261927
rc = server->ops->logoff(xid, ses);
19271928
if (rc)
19281929
cifs_server_dbg(VFS, "%s: Session Logoff failure rc=%d\n",
19291930
__func__, rc);
19301931
_free_xid(xid);
1932+
} else {
1933+
spin_unlock(&ses->ses_lock);
1934+
cifs_free_ipc(ses);
19311935
}
19321936

19331937
spin_lock(&cifs_tcp_ses_lock);

0 commit comments

Comments
 (0)