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

Wentao Liang posted 1 patch 1 week, 6 days ago
drivers/crypto/chelsio/chcr_algo.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] crypto: chelsio: fix inflight counter leak in chcr_aead_op()
Posted by Wentao Liang 1 week, 6 days ago
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@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 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
Re: [PATCH] crypto: chelsio: fix inflight counter leak in chcr_aead_op()
Posted by Herbert Xu 3 days, 9 hours ago
On Tue, May 26, 2026 at 04:06:55PM +0000, Wentao Liang wrote:
> 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@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>  drivers/crypto/chelsio/chcr_algo.c | 1 +
>  1 file changed, 1 insertion(+)

Please merge these patches into one.  There is no need to send
one patch per function.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt