diff options
author | Namjae Jeon <linkinjeon@kernel.org> | 2021-12-29 23:10:03 +0900 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2022-01-10 12:44:19 -0600 |
commit | 914d7e5709ac59ded70bea7956d408fe2acd7c3c (patch) | |
tree | de81a2369f17f36589ebfbca0a1af473d768e362 /fs/ksmbd/smb2misc.c | |
parent | 004443b3f6d722b455cf963ed7c3edd7f4772405 (diff) |
ksmbd: move credit charge deduction under processing request
Moves the credit charge deduction from total_credits under the processing
a request. When repeating smb2 lock request and other command request,
there will be a problem that ->total_credits does not decrease.
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/ksmbd/smb2misc.c')
-rw-r--r-- | fs/ksmbd/smb2misc.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/fs/ksmbd/smb2misc.c b/fs/ksmbd/smb2misc.c index 6892d1822269..fedcb753c7af 100644 --- a/fs/ksmbd/smb2misc.c +++ b/fs/ksmbd/smb2misc.c @@ -289,7 +289,7 @@ static int smb2_validate_credit_charge(struct ksmbd_conn *conn, unsigned int req_len = 0, expect_resp_len = 0, calc_credit_num, max_len; unsigned short credit_charge = le16_to_cpu(hdr->CreditCharge); void *__hdr = hdr; - int ret; + int ret = 0; switch (hdr->Command) { case SMB2_QUERY_INFO: @@ -332,10 +332,7 @@ static int smb2_validate_credit_charge(struct ksmbd_conn *conn, } spin_lock(&conn->credits_lock); - if (credit_charge <= conn->total_credits) { - conn->total_credits -= credit_charge; - ret = 0; - } else { + if (credit_charge > conn->total_credits) { ksmbd_debug(SMB, "Insufficient credits granted, given: %u, granted: %u\n", credit_charge, conn->total_credits); ret = 1; |