[PATCH 3/6] crypto: algif_aead - use sock_kzalloc in aead_accept_parent_nokey
From: Thorsten Blum
Date: Mon Apr 27 2026 - 06:44:28 EST
Replace sock_kmalloc() followed by memset(0) with sock_kzalloc() to
simplify aead_accept_parent_nokey().
Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
---
crypto/algif_aead.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/crypto/algif_aead.c b/crypto/algif_aead.c
index f8bd45f7dc83..83bb9a6bf85e 100644
--- a/crypto/algif_aead.c
+++ b/crypto/algif_aead.c
@@ -402,17 +402,15 @@ static int aead_accept_parent_nokey(void *private, struct sock *sk)
unsigned int len = sizeof(*ctx);
unsigned int ivlen = crypto_aead_ivsize(tfm);
- ctx = sock_kmalloc(sk, len, GFP_KERNEL);
+ ctx = sock_kzalloc(sk, len, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
- memset(ctx, 0, len);
- ctx->iv = sock_kmalloc(sk, ivlen, GFP_KERNEL);
+ ctx->iv = sock_kzalloc(sk, ivlen, GFP_KERNEL);
if (!ctx->iv) {
sock_kfree_s(sk, ctx, len);
return -ENOMEM;
}
- memset(ctx->iv, 0, ivlen);
INIT_LIST_HEAD(&ctx->tsgl_list);
ctx->len = len;