[PATCH 4/6] crypto: af_alg - use sock_kzalloc in alloc_result + accept_parent_nokey
From: Thorsten Blum
Date: Mon Apr 27 2026 - 06:44:53 EST
Replace sock_kmalloc() followed by memset(0) with sock_kzalloc() to
simplify hash_alloc_result() and hash_accept_parent_nokey().
Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
---
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);