From: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
To: Ayush Sawal <ayush.sawal@chelsio.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] crypto: chelsio - Fix potential NULL dereference after detach
Date: Mon, 16 Nov 2026 22:17:32 +0800 [thread overview]
Message-ID: <20261116-c29ba55625-crypto-chelsio@mail.sdu.edu.cn> (raw)
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
next reply other threads:[~2026-11-16 14:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 14:17 Guangshuo Li [this message]
2026-11-27 5:11 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116-c29ba55625-crypto-chelsio@mail.sdu.edu.cn \
--to=liguangshuo@mail.sdu.edu.cn \
--cc=ayush.sawal@chelsio.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®