Re: [PATCH v2] crypto: chelsio - Fix wrcount leak in AES encrypt and decrypt

From: Herbert Xu

Date: Fri Nov 13 2026 - 14:33:59 EST


On Fri, Nov 06, 2026 at 07:38:14AM -0000, Wentao Liang wrote:
> chcr_aes_encrypt() and chcr_aes_decrypt() increment the device inflight
> count with chcr_inc_wrcount() before building the work request, but both
> can return early without dropping the count.
>
> chcr_aes_encrypt() leaks the count when process_cipher() fails or
> returns no skb. chcr_aes_decrypt() leaks it when the tx queue is full or
> when process_cipher() fails and returns no skb. No completion can
> balance those increments, so every failed request permanently skews the
> count and eventually blocks the device from being detached, with the
> detach worker warning "CHCR:request Still Pending".
>
> chcr_aes_encrypt() already has an error label that calls
> chcr_dec_wrcount(), so jump to it on the remaining failure path. Add the
> same label to chcr_aes_decrypt() and jump to it from both of its failure
> paths, mirroring the encrypt side.
>
> Fixes: fef4912b66d6 ("crypto: chelsio - Handle PCI shutdown event")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
> ---
> Changes in v2:
> - Fix chcr_aes_encrypt() and chcr_aes_decrypt() in a single patch, as
> requested. Sorry for the late reply.
> - Link to v1: https://lore.kernel.org/all/20260916092527.2002187-1-vulab@xxxxxxxxxxx/
> https://lore.kernel.org/all/20260916092359.2001753-1-vulab@xxxxxxxxxxx/
> ---
> drivers/crypto/chelsio/chcr_algo.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)

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