]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb3: missing lock when picking channel
authorSteve French <stfrench@microsoft.com>
Thu, 25 Apr 2024 16:30:16 +0000 (11:30 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 May 2024 14:35:27 +0000 (16:35 +0200)
commit 8094a600245e9b28eb36a13036f202ad67c1f887 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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