* [PATCH] crypto: chelsio - Fix potential NULL dereference after detach
@ 2026-11-16 14:17 Guangshuo Li
2026-11-27 5:11 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Guangshuo Li @ 2026-11-16 14:17 UTC (permalink / raw)
To: Ayush Sawal, Herbert Xu, David S. Miller; +Cc: linux-crypto, linux-kernel
Detached contexts remain on the inactive list until module exit, but
their PCI driver data has already been cleared. Looking up the adapter
to reset its counters then dereferences NULL.
Skip the adapter lookup for detached contexts and free the contexts
without accessing the removed adapter.
This issue was found by our static analysis tool under development.
Fixes: c0271a053612 ("crypto: chelsio - Resetting crypto counters during the driver unregister")
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
drivers/crypto/chelsio/chcr_core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/chelsio/chcr_core.c b/drivers/crypto/chelsio/chcr_core.c
index 2609a8c3c18b..96ac6ea482b2 100644
--- a/drivers/crypto/chelsio/chcr_core.c
+++ b/drivers/crypto/chelsio/chcr_core.c
@@ -295,8 +295,10 @@ static void __exit chcr_crypto_exit(void)
kfree(u_ctx);
}
list_for_each_entry_safe(u_ctx, tmp, &drv_data.inact_dev, entry) {
- adap = padap(&u_ctx->dev);
- memset(&adap->chcr_stats, 0, sizeof(adap->chcr_stats));
+ if (u_ctx->dev.state != CHCR_DETACH) {
+ adap = padap(&u_ctx->dev);
+ memset(&adap->chcr_stats, 0, sizeof(adap->chcr_stats));
+ }
list_del(&u_ctx->entry);
kfree(u_ctx);
}
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] crypto: chelsio - Fix potential NULL dereference after detach
2026-11-16 14:17 [PATCH] crypto: chelsio - Fix potential NULL dereference after detach Guangshuo Li
@ 2026-11-27 5:11 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2026-11-27 5:11 UTC (permalink / raw)
To: Guangshuo Li; +Cc: ayush.sawal, davem, linux-crypto, linux-kernel
Guangshuo Li <liguangshuo@mail.sdu.edu.cn> wrote:
> Detached contexts remain on the inactive list until module exit, but
> their PCI driver data has already been cleared. Looking up the adapter
> to reset its counters then dereferences NULL.
>
> Skip the adapter lookup for detached contexts and free the contexts
> without accessing the removed adapter.
>
> This issue was found by our static analysis tool under development.
>
> Fixes: c0271a053612 ("crypto: chelsio - Resetting crypto counters during the driver unregister")
> Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
> ---
> drivers/crypto/chelsio/chcr_core.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
Patch applied. 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-27 5:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 14:17 [PATCH] crypto: chelsio - Fix potential NULL dereference after detach Guangshuo Li
2026-11-27 5:11 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®