Commit 3534b850 authored by Jeff Layton's avatar Jeff Layton Committed by Steve French

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: default avatarJeff Layton <jlayton@redhat.com>
Reviewed-by: default avatarPavel Shilovsky <piastry@etersoft.ru>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent 7d066459
...@@ -375,16 +375,15 @@ CIFSSMBNegotiate(const unsigned int xid, struct cifs_ses *ses) ...@@ -375,16 +375,15 @@ CIFSSMBNegotiate(const unsigned int xid, struct cifs_ses *ses)
int rc = 0; int rc = 0;
int bytes_returned; int bytes_returned;
int i; int i;
struct TCP_Server_Info *server; struct TCP_Server_Info *server = ses->server;
u16 count; u16 count;
unsigned int secFlags; unsigned int secFlags;
if (ses->server) if (!server) {
server = ses->server; WARN(1, "%s: server is NULL!\n", __func__);
else { return -EIO;
rc = -EIO;
return rc;
} }
rc = smb_init(SMB_COM_NEGOTIATE, 0, NULL /* no tcon yet */ , rc = smb_init(SMB_COM_NEGOTIATE, 0, NULL /* no tcon yet */ ,
(void **) &pSMB, (void **) &pSMBr); (void **) &pSMB, (void **) &pSMBr);
if (rc) if (rc)
......
...@@ -576,8 +576,10 @@ CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses, ...@@ -576,8 +576,10 @@ CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
u16 blob_len; u16 blob_len;
char *ntlmsspblob = NULL; char *ntlmsspblob = NULL;
if (ses == NULL) if (ses == NULL) {
WARN(1, "%s: ses == NULL!", __func__);
return -EINVAL; return -EINVAL;
}
type = ses->server->secType; type = ses->server->secType;
cifs_dbg(FYI, "sess setup type %d\n", type); cifs_dbg(FYI, "sess setup type %d\n", type);
......
...@@ -328,7 +328,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) ...@@ -328,7 +328,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
struct kvec iov[1]; struct kvec iov[1];
int rc = 0; int rc = 0;
int resp_buftype; int resp_buftype;
struct TCP_Server_Info *server; struct TCP_Server_Info *server = ses->server;
unsigned int sec_flags; unsigned int sec_flags;
u16 temp = 0; u16 temp = 0;
int blob_offset, blob_length; int blob_offset, blob_length;
...@@ -337,11 +337,9 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) ...@@ -337,11 +337,9 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
cifs_dbg(FYI, "Negotiate protocol\n"); cifs_dbg(FYI, "Negotiate protocol\n");
if (ses->server) if (!server) {
server = ses->server; WARN(1, "%s: server is NULL!\n", __func__);
else { return -EIO;
rc = -EIO;
return rc;
} }
rc = small_smb2_init(SMB2_NEGOTIATE, NULL, (void **) &req); 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,7 +478,7 @@ SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses,
int rc = 0; int rc = 0;
int resp_buftype; int resp_buftype;
__le32 phase = NtLmNegotiate; /* NTLMSSP, if needed, is multistage */ __le32 phase = NtLmNegotiate; /* NTLMSSP, if needed, is multistage */
struct TCP_Server_Info *server; struct TCP_Server_Info *server = ses->server;
unsigned int sec_flags; unsigned int sec_flags;
u8 temp = 0; u8 temp = 0;
u16 blob_length = 0; u16 blob_length = 0;
...@@ -490,11 +488,9 @@ SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses, ...@@ -490,11 +488,9 @@ SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses,
cifs_dbg(FYI, "Session Setup\n"); cifs_dbg(FYI, "Session Setup\n");
if (ses->server) if (!server) {
server = ses->server; WARN(1, "%s: server is NULL!\n", __func__);
else { return -EIO;
rc = -EIO;
return rc;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment