* [PATCH] crypto: safexcel - Unwind SHA3 initialization if HMAC setup fails
@ 2026-11-03 6:40 Wentao Liang
2026-11-03 7:10 ` Krzysztof Kozlowski
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-11-03 6:40 UTC (permalink / raw)
To: atenart, herbert; +Cc: davem, linux-crypto, linux-kernel, Wentao Liang, stable
safexcel_hmac_sha3_cra_init() first initializes the SHA3 context, which
allocates an ahash fallback. If allocating the shash transform or its
descriptor fails afterwards, that fallback is not released. The crypto
core does not invoke cra_exit after cra_init returns an error.
Call safexcel_sha3_cra_exit() on these failure paths to release the
resources acquired by safexcel_sha3_cra_init().
Fixes: 6c1c09b3dd0c ("crypto: inside-secure - Add HMAC-SHA3 family of authentication algorithms")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/crypto/inside-secure/safexcel_hash.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-secure/safexcel_hash.c
index 8f107da66685..308a1992a738 100644
--- a/drivers/crypto/inside-secure/safexcel_hash.c
+++ b/drivers/crypto/inside-secure/safexcel_hash.c
@@ -2649,17 +2649,24 @@ static int safexcel_hmac_sha3_cra_init(struct crypto_tfm *tfm, const char *alg)
/* Allocate precalc basic digest implementation */
ctx->shpre = crypto_alloc_shash(alg, 0, CRYPTO_ALG_NEED_FALLBACK);
- if (IS_ERR(ctx->shpre))
- return PTR_ERR(ctx->shpre);
+ if (IS_ERR(ctx->shpre)) {
+ ret = PTR_ERR(ctx->shpre);
+ goto err_sha3;
+ }
ctx->shdesc = kmalloc(sizeof(*ctx->shdesc) +
crypto_shash_descsize(ctx->shpre), GFP_KERNEL);
if (!ctx->shdesc) {
crypto_free_shash(ctx->shpre);
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto err_sha3;
}
ctx->shdesc->tfm = ctx->shpre;
return 0;
+
+err_sha3:
+ safexcel_sha3_cra_exit(tfm);
+ return ret;
}
static void safexcel_hmac_sha3_cra_exit(struct crypto_tfm *tfm)
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] crypto: safexcel - Unwind SHA3 initialization if HMAC setup fails
2026-11-03 6:40 [PATCH] crypto: safexcel - Unwind SHA3 initialization if HMAC setup fails Wentao Liang
@ 2026-11-03 7:10 ` Krzysztof Kozlowski
0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2026-11-03 7:10 UTC (permalink / raw)
To: Wentao Liang, atenart, herbert; +Cc: davem, linux-crypto, linux-kernel, stable
On 03/11/2026 07:40, Wentao Liang wrote:
> safexcel_hmac_sha3_cra_init() first initializes the SHA3 context, which
> allocates an ahash fallback. If allocating the shash transform or its
> descriptor fails afterwards, that fallback is not released. The crypto
> core does not invoke cra_exit after cra_init returns an error.
>
> Call safexcel_sha3_cra_exit() on these failure paths to release the
> resources acquired by safexcel_sha3_cra_init().
>
> Fixes: 6c1c09b3dd0c ("crypto: inside-secure - Add HMAC-SHA3 family of authentication algorithms")
> Cc: stable@vger.kernel.org
> Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Not even bothering to run checkpatch.
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Another fake identity of "vulab" doing exactly the same as other cases,
repeating same mistake of running unsupervised crappy bot even though
was asked multiple times to fix that.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-03 7:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 6:40 [PATCH] crypto: safexcel - Unwind SHA3 initialization if HMAC setup fails Wentao Liang
2026-11-03 7:10 ` Krzysztof Kozlowski
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®