Blob Blame History Raw
From: Steve French <stfrench@microsoft.com>
Date: Thu, 11 Nov 2021 16:18:14 -0600
Subject: [PATCH] smb3: add additional null check in SMB2_tcon
Git-commit: bac35395d27c4b406fec0a6c2528744f64de6e13
References: bsc#1190317
Patch-mainline: v5.16-rc1

Although unlikely to be possible for rsp to be null here,
the check is safer to add, and quiets a Coverity warning.

Addresses-Coverity: 1420428 ("Explicit null dereferenced")
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
Acked-by: Paulo Alcantara <palcantara@suse.de>
---
 fs/cifs/smb2pdu.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -1702,7 +1702,7 @@ SMB2_tcon(const unsigned int xid, struct
 	cifs_small_buf_release(req);
 	rsp = (struct smb2_tree_connect_rsp *)rsp_iov.iov_base;
 	trace_smb3_tcon(xid, tcon->tid, ses->Suid, tree, rc);
-	if (rc != 0) {
+	if ((rc != 0) || (rsp == NULL)) {
 		if (tcon) {
 			cifs_stats_fail_inc(tcon, SMB2_TREE_CONNECT_HE);
 			tcon->need_reconnect = true;