[PATCH v2 4/9] crypto: padlock-aes - clear the crypto_aes_ctx when done

From: Thomas Huth

Date: Mon Aug 03 2026 - 05:53:42 EST


From: Thomas Huth <thuth@xxxxxxxxxx>

Clear the crypto_aes_ctx structure via __cleanup(aes_clear_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/padlock-aes.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c
index 1be549a07a219..ac0aace62b299 100644
--- a/drivers/crypto/padlock-aes.c
+++ b/drivers/crypto/padlock-aes.c
@@ -109,7 +109,7 @@ static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
{
struct aes_ctx *ctx = aes_ctx(tfm);
const __le32 *key = (const __le32 *)in_key;
- struct crypto_aes_ctx gen_aes;
+ struct crypto_aes_ctx gen_aes __cleanup(aes_clear_ctx);
int cpu;

if (key_len % 8)
--
2.55.0