Commit 05d0f8f5 authored by Steve French's avatar Steve French

smb3: move server check earlier when setting channel sequence number

Smatch warning pointed out by Dan Carpenter:

    fs/smb/client/smb2pdu.c:105 smb2_hdr_assemble()
    warn: variable dereferenced before check 'server' (see line 95)

Fixes: 09ee7a3b ("[SMB3] send channel sequence number in SMB3 requests after reconnects")
Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 0bb80ecc
......@@ -92,17 +92,22 @@ smb2_hdr_assemble(struct smb2_hdr *shdr, __le16 smb2_cmd,
shdr->ProtocolId = SMB2_PROTO_NUMBER;
shdr->StructureSize = cpu_to_le16(64);
shdr->Command = smb2_cmd;
if (server->dialect >= SMB30_PROT_ID) {
/* After reconnect SMB3 must set ChannelSequence on subsequent reqs */
smb3_hdr = (struct smb3_hdr_req *)shdr;
/* if primary channel is not set yet, use default channel for chan sequence num */
if (SERVER_IS_CHAN(server))
smb3_hdr->ChannelSequence =
cpu_to_le16(server->primary_server->channel_sequence_num);
else
smb3_hdr->ChannelSequence = cpu_to_le16(server->channel_sequence_num);
}
if (server) {
/* After reconnect SMB3 must set ChannelSequence on subsequent reqs */
if (server->dialect >= SMB30_PROT_ID) {
smb3_hdr = (struct smb3_hdr_req *)shdr;
/*
* if primary channel is not set yet, use default
* channel for chan sequence num
*/
if (SERVER_IS_CHAN(server))
smb3_hdr->ChannelSequence =
cpu_to_le16(server->primary_server->channel_sequence_num);
else
smb3_hdr->ChannelSequence =
cpu_to_le16(server->channel_sequence_num);
}
spin_lock(&server->req_lock);
/* Request up to 10 credits but don't go over the limit. */
if (server->credits >= server->max_credits)
......
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