diff options
author | Namjae Jeon <linkinjeon@kernel.org> | 2021-12-29 23:10:03 +0900 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-01-27 11:02:53 +0100 |
commit | 0aadd32bebc9506b1fc88ab43c6174c2e371ad7b (patch) | |
tree | 74a92ff0c4700eb5dbab49e12db57957fbe14f45 /fs/ksmbd/smb2misc.c | |
parent | 40fc68aeeb240afb25d7f63bb746f62b8d1f7ec9 (diff) |
ksmbd: move credit charge deduction under processing request
commit 914d7e5709ac59ded70bea7956d408fe2acd7c3c upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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 f8f031978d06..e4a28eae51b2 100644 --- a/fs/ksmbd/smb2misc.c +++ b/fs/ksmbd/smb2misc.c @@ -290,7 +290,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: @@ -333,10 +333,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; |