aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2013-05-24 07:41:01 -0400
committerSteve French <smfrench@gmail.com>2013-06-24 02:56:40 -0400
commit3534b8508e4b21eec0b7b839f7234a9b6fe27d03 (patch)
treeabca5bc7bb74168ffb6a8a9ff09cd99a3217f639 /fs
parent7d066459697610f6e755a7cfe199c3c6b142fb85 (diff)
cifs: throw a warning if negotiate or sess_setup ops are passed NULL server or session pointers
These look pretty cargo-culty to me, but let's be certain. Leave them in place for now. Pop a WARN if it ever does happen. Also, move to a more standard idiom for setting the "server" pointer. Signed-off-by: Jeff Layton <jlayton@redhat.com> Reviewed-by: Pavel Shilovsky <piastry@etersoft.ru> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/cifssmb.c11
-rw-r--r--fs/cifs/sess.c4
-rw-r--r--fs/cifs/smb2pdu.c20
3 files changed, 16 insertions, 19 deletions
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index a58dc77cc443..c1c2006376a1 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -375,16 +375,15 @@ CIFSSMBNegotiate(const unsigned int xid, struct cifs_ses *ses)
375 int rc = 0; 375 int rc = 0;
376 int bytes_returned; 376 int bytes_returned;
377 int i; 377 int i;
378 struct TCP_Server_Info *server; 378 struct TCP_Server_Info *server = ses->server;
379 u16 count; 379 u16 count;
380 unsigned int secFlags; 380 unsigned int secFlags;
381 381
382 if (ses->server) 382 if (!server) {
383 server = ses->server; 383 WARN(1, "%s: server is NULL!\n", __func__);
384 else { 384 return -EIO;
385 rc = -EIO;
386 return rc;
387 } 385 }
386
388 rc = smb_init(SMB_COM_NEGOTIATE, 0, NULL /* no tcon yet */ , 387 rc = smb_init(SMB_COM_NEGOTIATE, 0, NULL /* no tcon yet */ ,
389 (void **) &pSMB, (void **) &pSMBr); 388 (void **) &pSMB, (void **) &pSMBr);
390 if (rc) 389 if (rc)
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index 838e2240fc55..e8c5dc9f3386 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -576,8 +576,10 @@ CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
576 u16 blob_len; 576 u16 blob_len;
577 char *ntlmsspblob = NULL; 577 char *ntlmsspblob = NULL;
578 578
579 if (ses == NULL) 579 if (ses == NULL) {
580 WARN(1, "%s: ses == NULL!", __func__);
580 return -EINVAL; 581 return -EINVAL;
582 }
581 583
582 type = ses->server->secType; 584 type = ses->server->secType;
583 cifs_dbg(FYI, "sess setup type %d\n", type); 585 cifs_dbg(FYI, "sess setup type %d\n", type);
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 2b95ce2b54e8..3af66aa18d3b 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -328,7 +328,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
328 struct kvec iov[1]; 328 struct kvec iov[1];
329 int rc = 0; 329 int rc = 0;
330 int resp_buftype; 330 int resp_buftype;
331 struct TCP_Server_Info *server; 331 struct TCP_Server_Info *server = ses->server;
332 unsigned int sec_flags; 332 unsigned int sec_flags;
333 u16 temp = 0; 333 u16 temp = 0;
334 int blob_offset, blob_length; 334 int blob_offset, blob_length;
@@ -337,11 +337,9 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
337 337
338 cifs_dbg(FYI, "Negotiate protocol\n"); 338 cifs_dbg(FYI, "Negotiate protocol\n");
339 339
340 if (ses->server) 340 if (!server) {
341 server = ses->server; 341 WARN(1, "%s: server is NULL!\n", __func__);
342 else { 342 return -EIO;
343 rc = -EIO;
344 return rc;
345 } 343 }
346 344
347 rc = small_smb2_init(SMB2_NEGOTIATE, NULL, (void **) &req); 345 rc = small_smb2_init(SMB2_NEGOTIATE, NULL, (void **) &req);
@@ -480,7 +478,7 @@ SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses,
480 int rc = 0; 478 int rc = 0;
481 int resp_buftype; 479 int resp_buftype;
482 __le32 phase = NtLmNegotiate; /* NTLMSSP, if needed, is multistage */ 480 __le32 phase = NtLmNegotiate; /* NTLMSSP, if needed, is multistage */
483 struct TCP_Server_Info *server; 481 struct TCP_Server_Info *server = ses->server;
484 unsigned int sec_flags; 482 unsigned int sec_flags;
485 u8 temp = 0; 483 u8 temp = 0;
486 u16 blob_length = 0; 484 u16 blob_length = 0;
@@ -490,11 +488,9 @@ SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses,
490 488
491 cifs_dbg(FYI, "Session Setup\n"); 489 cifs_dbg(FYI, "Session Setup\n");
492 490
493 if (ses->server) 491 if (!server) {
494 server = ses->server; 492 WARN(1, "%s: server is NULL!\n", __func__);
495 else { 493 return -EIO;
496 rc = -EIO;
497 return rc;
498 } 494 }
499 495
500 /* 496 /*