]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb3: check for null tcon
authorSteve French <stfrench@microsoft.com>
Tue, 24 May 2022 01:42:03 +0000 (20:42 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:29:52 +0000 (10:29 +0200)
[ Upstream commit bbdf6cf56c88845fb0b713cbf5c6623c53fe40d8 ]

Although unlikely to be null, it is confusing to use a pointer
before checking for it to be null so move the use down after
null check.

Addresses-Coverity: 1517586 ("Null pointer dereferences  (REVERSE_INULL)")
Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/cifs/smb2ops.c

index 2df9aab12db7a344b45796083909963459fc6418..861291662c95d5a3cdef73fe9567a9a85c57d3b4 100644 (file)
@@ -760,8 +760,8 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
                struct cifs_sb_info *cifs_sb,
                struct cached_fid **cfid)
 {
-       struct cifs_ses *ses = tcon->ses;
-       struct TCP_Server_Info *server = ses->server;
+       struct cifs_ses *ses;
+       struct TCP_Server_Info *server;
        struct cifs_open_parms oparms;
        struct smb2_create_rsp *o_rsp = NULL;
        struct smb2_query_info_rsp *qi_rsp = NULL;
@@ -779,6 +779,9 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
        if (tcon->nohandlecache)
                return -ENOTSUPP;
 
+       ses = tcon->ses;
+       server = ses->server;
+
        if (cifs_sb->root == NULL)
                return -ENOENT;