summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve French <stfrench@microsoft.com>2021-11-16 01:02:27 +0100
committerSteve French <stfrench@microsoft.com>2021-11-16 17:46:22 +0100
commit446e21482e8c10b96d540862c5f6a37009436f00 (patch)
tree0b2c46436f2ec9cc018b9725cd8d2410d4b5b330
parentcifs: move debug print out of spinlock (diff)
downloadlinux-446e21482e8c10b96d540862c5f6a37009436f00.tar.xz
linux-446e21482e8c10b96d540862c5f6a37009436f00.zip
cifs: protect srv_count with cifs_tcp_ses_lock
Updates to the srv_count field are protected elsewhere with the cifs_tcp_ses_lock spinlock. Add one missing place (cifs_get_tcp_sesion). CC: Shyam Prasad N <sprasad@microsoft.com> Addresses-Coverity: 1494149 ("Data Race Condition") Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Signed-off-by: Steve French <stfrench@microsoft.com>
-rw-r--r--fs/cifs/connect.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 82577a7a5bb1..b98711b62897 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1452,8 +1452,10 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx,
tcp_ses->max_in_flight = 0;
tcp_ses->credits = 1;
if (primary_server) {
+ spin_lock(&cifs_tcp_ses_lock);
++primary_server->srv_count;
tcp_ses->primary_server = primary_server;
+ spin_unlock(&cifs_tcp_ses_lock);
}
init_waitqueue_head(&tcp_ses->response_q);
init_waitqueue_head(&tcp_ses->request_q);