Commit 943fb67b authored by Steve French's avatar Steve French

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: default avatarPaulo Alcantara (SUSE) <pc@manguebit.com>
Reviewed-by: default avatarBharath SM <bharathsm@microsoft.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent d906be3f
...@@ -1916,18 +1916,22 @@ void cifs_put_smb_ses(struct cifs_ses *ses) ...@@ -1916,18 +1916,22 @@ void cifs_put_smb_ses(struct cifs_ses *ses)
/* ses_count can never go negative */ /* ses_count can never go negative */
WARN_ON(ses->ses_count < 0); WARN_ON(ses->ses_count < 0);
spin_lock(&ses->ses_lock);
if (ses->ses_status == SES_GOOD) if (ses->ses_status == SES_GOOD)
ses->ses_status = SES_EXITING; ses->ses_status = SES_EXITING;
cifs_free_ipc(ses);
if (ses->ses_status == SES_EXITING && server->ops->logoff) { if (ses->ses_status == SES_EXITING && server->ops->logoff) {
spin_unlock(&ses->ses_lock);
cifs_free_ipc(ses);
xid = get_xid(); xid = get_xid();
rc = server->ops->logoff(xid, ses); rc = server->ops->logoff(xid, ses);
if (rc) if (rc)
cifs_server_dbg(VFS, "%s: Session Logoff failure rc=%d\n", cifs_server_dbg(VFS, "%s: Session Logoff failure rc=%d\n",
__func__, rc); __func__, rc);
_free_xid(xid); _free_xid(xid);
} else {
spin_unlock(&ses->ses_lock);
cifs_free_ipc(ses);
} }
spin_lock(&cifs_tcp_ses_lock); spin_lock(&cifs_tcp_ses_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment