smb3: add missing null server pointer check
authorSteve French <stfrench@microsoft.com>
Mon, 5 Feb 2024 20:43:17 +0000 (14:43 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Mar 2024 12:35:03 +0000 (13:35 +0100)
commit 45be0882c5f91e1b92e645001dd1a53b3bd58c97 upstream.

Address static checker warning in cifs_ses_get_chan_index():
    warn: variable dereferenced before check 'server'
To be consistent, and reduce risk, we should add another check
for null server pointer.

Fixes: 88675b22d34e ("cifs: do not search for channel if server is terminating")
Reported-by: Dan Carpenter <dan.carpenter@linaro.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/sess.c

index 07726b456a0a87a34bdc8e9b86fa42c977fadbc0..2fc2fbb260bf0da49ad043a016b4859f71785aeb 100644 (file)
@@ -76,7 +76,7 @@ cifs_ses_get_chan_index(struct cifs_ses *ses,
        unsigned int i;
 
        /* if the channel is waiting for termination */
-       if (server->terminate)
+       if (server && server->terminate)
                return CIFS_INVAL_CHAN_INDEX;
 
        for (i = 0; i < ses->chan_count; i++) {