]> git.dujemihanovic.xyz Git - linux.git/commitdiff
smb3: missing lock when picking channel
authorSteve French <stfrench@microsoft.com>
Thu, 25 Apr 2024 16:30:16 +0000 (11:30 -0500)
committerSteve French <stfrench@microsoft.com>
Thu, 25 Apr 2024 17:47:23 +0000 (12:47 -0500)
Coverity spotted a place where we should have been holding the
channel lock when accessing the ses channel index.

Addresses-Coverity: 1582039 ("Data race condition (MISSING_LOCK)")
Cc: stable@vger.kernel.org
Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/transport.c

index 994d70193432978de213a19a0f9933bd90e63671..e1a79e031b28ccc85571720bc0510c219bc8daef 100644 (file)
@@ -1057,9 +1057,11 @@ struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses)
                index = (uint)atomic_inc_return(&ses->chan_seq);
                index %= ses->chan_count;
        }
+
+       server = ses->chans[index].server;
        spin_unlock(&ses->chan_lock);
 
-       return ses->chans[index].server;
+       return server;
 }
 
 int