mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] crypto: xilinx - use kfree_sensitive() in cleanup paths
@ 2026-09-08 19:00 Thorsten Blum
  2026-09-09  9:27 ` Jain, Harsh (AECG-SSW)
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-09-08 19:00 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, Michal Simek, Harsh Jain,
	Uwe Kleine-König (The Capable Hub),
	Danilo Krummrich, Takashi Sakamoto
  Cc: Thorsten Blum, linux-crypto, linux-arm-kernel, linux-kernel

In zynqmp_aes_aead_cipher() and versal_aes_aead_cipher(), replace
memzero_explicit() followed by kfree() with kfree_sensitive() to
simplify the code.

Signed-off-by: Thorsten Blum <blum@kernel.org>
---
 drivers/crypto/xilinx/zynqmp-aes-gcm.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/crypto/xilinx/zynqmp-aes-gcm.c b/drivers/crypto/xilinx/zynqmp-aes-gcm.c
index ebee37dddb1f..d9bd6dcd23a6 100644
--- a/drivers/crypto/xilinx/zynqmp-aes-gcm.c
+++ b/drivers/crypto/xilinx/zynqmp-aes-gcm.c
@@ -230,10 +230,8 @@ static int zynqmp_aes_aead_cipher(struct aead_request *req)
 	}
 
 freemem:
-	memzero_explicit(kbuf, dma_size);
-	kfree(kbuf);
-	memzero_explicit(dmabuf, sizeof(struct zynqmp_aead_hw_req) + GCM_AES_IV_SIZE);
-	kfree(dmabuf);
+	kfree_sensitive(kbuf);
+	kfree_sensitive(dmabuf);
 
 	return ret;
 }
@@ -364,11 +362,9 @@ static int versal_aes_aead_cipher(struct aead_request *req)
 	if (unlikely(dma_addr_hw_req))
 		dma_unmap_single(dev, dma_addr_hw_req, dmabuf_size, DMA_BIDIRECTIONAL);
 buf2_free:
-	memzero_explicit(dmabuf, dmabuf_size);
-	kfree(dmabuf);
+	kfree_sensitive(dmabuf);
 buf1_free:
-	memzero_explicit(kbuf, kbuf_size);
-	kfree(kbuf);
+	kfree_sensitive(kbuf);
 err:
 	return ret;
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-09  9:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-08 19:00 [PATCH] crypto: xilinx - use kfree_sensitive() in cleanup paths Thorsten Blum
2026-09-09  9:27 ` Jain, Harsh (AECG-SSW)

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®