Thread (9 messages) 9 messages, 2 authors, 10d ago
COOLING10d REVIEWED: 3 (3M)

[PATCH RESEND 4/6] crypto: af_alg - use sock_kzalloc in alloc_result + accept_parent_nokey

From: Thorsten Blum <thorsten.blum@linux.dev>
Date: 2026-05-27 08:26:01
Also in: linux-crypto, lkml
Subsystem: crypto api, the rest · Maintainers: Herbert Xu, "David S. Miller", Linus Torvalds

Replace sock_kmalloc() followed by memset(0) with sock_kzalloc() to
simplify hash_alloc_result() and hash_accept_parent_nokey().

Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 crypto/algif_hash.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c
index 4d3dfc60a16a..02c0e448390d 100644
--- a/crypto/algif_hash.c
+++ b/crypto/algif_hash.c
@@ -38,12 +38,10 @@ static int hash_alloc_result(struct sock *sk, struct hash_ctx *ctx)
 
 	ds = crypto_ahash_digestsize(crypto_ahash_reqtfm(&ctx->req));
 
-	ctx->result = sock_kmalloc(sk, ds, GFP_KERNEL);
+	ctx->result = sock_kzalloc(sk, ds, GFP_KERNEL);
 	if (!ctx->result)
 		return -ENOMEM;
 
-	memset(ctx->result, 0, ds);
-
 	return 0;
 }
 
@@ -412,11 +410,10 @@ static int hash_accept_parent_nokey(void *private, struct sock *sk)
 	struct hash_ctx *ctx;
 	unsigned int len = sizeof(*ctx) + crypto_ahash_reqsize(tfm);
 
-	ctx = sock_kmalloc(sk, len, GFP_KERNEL);
+	ctx = sock_kzalloc(sk, len, GFP_KERNEL);
 	if (!ctx)
 		return -ENOMEM;
 
-	memset(ctx, 0, len);
 	ctx->len = len;
 	crypto_init_wait(&ctx->wait);
 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help