* [PATCH] crypto: octeontx2 - Unwind allocations when AEAD initialization fails
@ 2026-11-03 6:42 Wentao Liang
2026-11-03 7:10 ` Krzysztof Kozlowski
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-11-03 6:42 UTC (permalink / raw)
To: schalla, bbhushan2, herbert
Cc: davem, linux-crypto, linux-kernel, Wentao Liang, stable
cpt_aead_init() allocates a hash transform, descriptor and pads before
looking up a CPT device and initializing the hardware context. Failures
in those later steps return without freeing the earlier allocations.
If fallback allocation fails, the hardware context is also left mapped
and allocated. The algorithm exit callback does not run after a failed
initialization.
Release the hardware context when fallback initialization fails and free
the hash resources on all three failure paths.
Fixes: 6f03f0e8b6c8 ("crypto: octeontx2 - register with linux crypto framework")
Fixes: e92971117c2c ("crypto: octeontx2 - add ctx_val workaround")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
.../crypto/marvell/octeontx2/otx2_cptvf_algs.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c b/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
index 9eb5dc0a4da6..8d74e0274fdf 100644
--- a/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
+++ b/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
@@ -671,14 +671,24 @@ static int cpt_aead_init(struct crypto_aead *atfm, u8 cipher_type, u8 mac_type)
ret = get_se_device(&pdev, &cpu_num);
if (ret)
- return ret;
+ goto err_free_hash;
ctx->pdev = pdev;
ret = cn10k_cpt_hw_ctx_init(pdev, &ctx->er_ctx);
if (ret)
- return ret;
+ goto err_free_hash;
- return cpt_aead_fallback_init(ctx, alg);
+ ret = cpt_aead_fallback_init(ctx, alg);
+ if (!ret)
+ return 0;
+
+ cn10k_cpt_hw_ctx_clear(pdev, &ctx->er_ctx);
+err_free_hash:
+ kfree(ctx->opad);
+ kfree(ctx->ipad);
+ kfree(ctx->sdesc);
+ crypto_free_shash(ctx->hashalg);
+ return ret;
}
static int otx2_cpt_aead_cbc_aes_sha1_init(struct crypto_aead *tfm)
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] crypto: octeontx2 - Unwind allocations when AEAD initialization fails
2026-11-03 6:42 [PATCH] crypto: octeontx2 - Unwind allocations when AEAD initialization 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, schalla, bbhushan2, herbert
Cc: davem, linux-crypto, linux-kernel, stable
On 03/11/2026 07:42, Wentao Liang wrote:
> cpt_aead_init() allocates a hash transform, descriptor and pads before
> looking up a CPT device and initializing the hardware context. Failures
> in those later steps return without freeing the earlier allocations.
> If fallback allocation fails, the hardware context is also left mapped
> and allocated. The algorithm exit callback does not run after a failed
> initialization.
>
> Release the hardware context when fallback initialization fails and free
> the hash resources on all three failure paths.
>
> Fixes: 6f03f0e8b6c8 ("crypto: octeontx2 - register with linux crypto framework")
> Fixes: e92971117c2c ("crypto: octeontx2 - add ctx_val workaround")
> Cc: stable@vger.kernel.org
> Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
> 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:42 [PATCH] crypto: octeontx2 - Unwind allocations when AEAD initialization 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®