]> git.baikalelectronics.ru Git - kernel.git/commitdiff
smb3: correct server pointer dereferencing check to be more consistent
authorSteve French <stfrench@microsoft.com>
Thu, 23 Sep 2021 23:52:40 +0000 (18:52 -0500)
committerSteve French <stfrench@microsoft.com>
Fri, 24 Sep 2021 02:12:23 +0000 (21:12 -0500)
Address warning:

    fs/smbfs_client/misc.c:273 header_assemble()
    warn: variable dereferenced before check 'treeCon->ses->server'

Pointed out by Dan Carpenter via smatch code analysis tool

Although the check is likely unneeded, adding it makes the code
more consistent and easier to read, as the same check is
done elsewhere in the function.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/misc.c

index f2916b51652aea6554bc993b1392153ec9170471..bb1185fff8cc4d6b760cf01c22a72e50f575c591 100644 (file)
@@ -264,7 +264,8 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
 
                        /* Uid is not converted */
                        buffer->Uid = treeCon->ses->Suid;
-                       buffer->Mid = get_next_mid(treeCon->ses->server);
+                       if (treeCon->ses->server)
+                               buffer->Mid = get_next_mid(treeCon->ses->server);
                }
                if (treeCon->Flags & SMB_SHARE_IS_IN_DFS)
                        buffer->Flags2 |= SMBFLG2_DFS;