[PATCH v5 04/10] crypto: sa2ul - clear the crypto_aes_ctx when done

From: Thomas Huth

Date: Mon Aug 10 2026 - 05:33:33 EST


From: Thomas Huth <thuth@xxxxxxxxxx>

Clear the crypto_aes_ctx structure via __cleanup(aes_zeroize_ctx) when
we're done with it to avoid that key data could leak on the stack.

Signed-off-by: Thomas Huth <thuth@xxxxxxxxxx>
---
drivers/crypto/sa2ul.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/sa2ul.c b/drivers/crypto/sa2ul.c
index d865fd4a098cb..f1a7c2cc7a1af 100644
--- a/drivers/crypto/sa2ul.c
+++ b/drivers/crypto/sa2ul.c
@@ -465,7 +465,7 @@ static void sa_prepare_iopads(struct algo_data *data, const u8 *key,
/* Derive the inverse key used in AES-CBC decryption operation */
static inline int sa_aes_inv_key(u8 *inv_key, const u8 *key, u16 key_sz)
{
- struct crypto_aes_ctx ctx;
+ struct crypto_aes_ctx ctx __cleanup(aes_zeroize_ctx);
int key_pos;

if (aes_expandkey(&ctx, key, key_sz)) {
--
2.55.0