linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] cifs: smb2pdu: Fix potential NULL pointer dereference
@ 2018-04-03 21:00 Gustavo A. R. Silva
  2018-04-04 10:18 ` Aurélien Aptel
  0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2018-04-03 21:00 UTC (permalink / raw)
  To: Ronnie Sahlberg, Steve French
  Cc: linux-cifs, samba-technical, linux-kernel, 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")
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
Changes in v2:
 - Update subject.

 fs/cifs/smb2pdu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index f7741ce..e5ac474 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -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)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] cifs: smb2pdu: Fix potential NULL pointer dereference
  2018-04-03 21:00 [PATCH v2] cifs: smb2pdu: Fix potential NULL pointer dereference Gustavo A. R. Silva
@ 2018-04-04 10:18 ` Aurélien Aptel
  0 siblings, 0 replies; 2+ messages in thread
From: Aurélien Aptel @ 2018-04-04 10:18 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Ronnie Sahlberg, Steve French
  Cc: linux-cifs, samba-technical, linux-kernel, Gustavo A. R. Silva

"Gustavo A. R. Silva" <garsilva@embeddedor.com> writes:
> 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")
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>

Reviewed-by: Aurelien Aptel <aaptel@suse.com>

-- 
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-04-04 10:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-03 21:00 [PATCH v2] cifs: smb2pdu: Fix potential NULL pointer dereference Gustavo A. R. Silva
2018-04-04 10:18 ` Aurélien Aptel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).