[PATCH] crypto: chelsio: fix inflight counter leak in chcr_aead_op()

From: Wentao Liang

Date: Tue May 26 2026 - 12:20:50 EST


chcr_aead_op() increments cdev->inflight via atomic_inc() before
submitting the AEAD operation. If the operation fails after the
increment (e.g., chcr_start_aead() returns an error), the function
returns without decrementing cdev->inflight. This leaks a reference
on the inflight counter, preventing proper teardown sequencing.

Add atomic_dec(&cdev->inflight) on the error path to balance the
counter.

Fixes: d91a3159e8d9 ("Crypto/chcr: fix gcm-aes and rfc4106-gcm failed tests")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/crypto/chelsio/chcr_algo.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
index eece1ac1085a..14a708defcd4 100644
--- a/drivers/crypto/chelsio/chcr_algo.c
+++ b/drivers/crypto/chelsio/chcr_algo.c
@@ -3636,6 +3636,7 @@ static int chcr_aead_op(struct aead_request *req,
crypto_ipsec_check_assoclen(req->assoclen) != 0) {
pr_err("RFC4106: Invalid value of assoclen %d\n",
req->assoclen);
+ chcr_dec_wrcount(cdev);
return -EINVAL;
}

--
2.34.1