diff options
author | Pavel Shilovsky <pshilov@microsoft.com> | 2019-01-22 16:50:21 -0800 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2019-01-24 14:52:06 -0600 |
commit | 3d3003fce8e837acc4e3960fe3cbabebc356dcb5 (patch) | |
tree | 45c36004bb21d46ef0a922a5e160a6623ae66338 /fs/cifs/smb2ops.c | |
parent | ec678eae746dd25766a61c4095e2b649d3b20b09 (diff) | |
download | linux-stable-3d3003fce8e837acc4e3960fe3cbabebc356dcb5.tar.gz linux-stable-3d3003fce8e837acc4e3960fe3cbabebc356dcb5.tar.bz2 linux-stable-3d3003fce8e837acc4e3960fe3cbabebc356dcb5.zip |
CIFS: Fix credit calculations in compound mid callback
The current code doesn't do proper accounting for credits
in SMB1 case: it adds one credit per response only if we get
a complete response while it needs to return it unconditionally.
Fix this and also include malformed responses for SMB2+ into
accounting for credits because such responses have Credit
Granted field, thus nothing prevents to get a proper credit
value from them.
Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs/smb2ops.c')
-rw-r--r-- | fs/cifs/smb2ops.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 73f9c6af4065..153238fc4fa9 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -154,7 +154,11 @@ smb2_get_credits(struct mid_q_entry *mid) { struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)mid->resp_buf; - return le16_to_cpu(shdr->CreditRequest); + if (mid->mid_state == MID_RESPONSE_RECEIVED + || mid->mid_state == MID_RESPONSE_MALFORMED) + return le16_to_cpu(shdr->CreditRequest); + + return 0; } static int |