Skip to contentSkip to conversation

cifs: cifssmb: Fix potential NULL pointer dereference

PATCH Superseded Gustavo A. R. Silva 2 participants 2 messages Apr 3, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: cifssmb: Fix potential NULL pointer dereference

tcon->ses is being dereferenced before it is null checked, hence there is a potential null pointer dereference.

Fix this by moving the pointer dereference after tcon->ses has been properly null checked.

Addresses-Coverity-ID: 1467426 ("Dereference before null check")

Fixes 93012bf98416 ("cifs: add server->vals->header_preamble_size")
---
 fs/cifs/smb2pdu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/cifs/smb2pdu.c +3 -1
index f7741ce..e5ac474 100644
@@ -3454,7 +3454,7 @@ static int
 build_qfs_info_req(struct kvec *iov, struct cifs_tcon *tcon, int level,
 		   int outbuf_len, u64 persistent_fid, u64 volatile_fid)
 {
-	struct TCP_Server_Info *server = tcon->ses->server;
+	struct TCP_Server_Info *server;
 	int rc;
 	struct smb2_query_info_req *req;
 	unsigned int total_len;
@@ -3464,6 +3464,8 @@ build_qfs_info_req(struct kvec *iov, struct cifs_tcon *tcon, int level,
 	if ((tcon->ses == NULL) || (tcon->ses->server == NULL))
 		return -EIO;
 
+	server = tcon->ses->server;
+
 	rc = smb2_plain_req_init(SMB2_QUERY_INFO, tcon, (void **) &req,
 			     &total_len);
 	if (rc)
Signature · 1 line
2.7.4
#1 lore raw

Hi,

I noticed the subject was incorrect. Drop this patch, please.

I just sent v2.

Thanks
--
Gustavo

Quoted 36 lines · Gustavo A. R. Silva

tcon->ses is being dereferenced before it is null checked, hence there is a potential null pointer dereference.

Fix this by moving the pointer dereference after tcon->ses has been properly null checked.

Addresses-Coverity-ID: 1467426 ("Dereference before null check")

Fixes 93012bf98416 ("cifs: add server->vals->header_preamble_size")
---
  fs/cifs/smb2pdu.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
fs/cifs/smb2pdu.c +3 -1
index f7741ce..e5ac474 100644
@@ -3454,7 +3454,7 @@ static int
  build_qfs_info_req(struct kvec *iov, struct cifs_tcon *tcon, int level,
  		   int outbuf_len, u64 persistent_fid, u64 volatile_fid)
  {
-	struct TCP_Server_Info *server = tcon->ses->server;
+	struct TCP_Server_Info *server;
  	int rc;
  	struct smb2_query_info_req *req;
  	unsigned int total_len;
@@ -3464,6 +3464,8 @@ build_qfs_info_req(struct kvec *iov, struct cifs_tcon *tcon, int level,
  	if ((tcon->ses == NULL) || (tcon->ses->server == NULL))
  		return -EIO;
 
+	server = tcon->ses->server;
+
  	rc = smb2_plain_req_init(SMB2_QUERY_INFO, tcon, (void **) &req,
  			     &total_len);
  	if (rc)