[PATCH] crypto: all - alloc and init all req alloc as zero

From: Zhang Yiqun
Date: Thu Jul 27 2023 - 04:14:41 EST


This patch is to change all req struct alloc function from kmalloc
to kzalloc. Sometimes, it will incur some errors without initialized
zero.

Signed-off-by: Zhang Yiqun <zhangyiqun@xxxxxxxxxxxxxx>
---
include/crypto/akcipher.h | 2 +-
include/crypto/hash.h | 2 +-
include/crypto/kpp.h | 2 +-
include/crypto/skcipher.h | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/crypto/akcipher.h b/include/crypto/akcipher.h
index 670508f1dca1..b6f2121fcb85 100644
--- a/include/crypto/akcipher.h
+++ b/include/crypto/akcipher.h
@@ -223,7 +223,7 @@ static inline struct akcipher_request *akcipher_request_alloc(
{
struct akcipher_request *req;

- req = kmalloc(sizeof(*req) + crypto_akcipher_reqsize(tfm), gfp);
+ req = kzalloc(sizeof(*req) + crypto_akcipher_reqsize(tfm), gfp);
if (likely(req))
akcipher_request_set_tfm(req, tfm);

diff --git a/include/crypto/hash.h b/include/crypto/hash.h
index f7c2a22cd776..38429fb7bbf7 100644
--- a/include/crypto/hash.h
+++ b/include/crypto/hash.h
@@ -651,7 +651,7 @@ static inline struct ahash_request *ahash_request_alloc(
{
struct ahash_request *req;

- req = kmalloc(sizeof(struct ahash_request) +
+ req = kzalloc(sizeof(struct ahash_request) +
crypto_ahash_reqsize(tfm), gfp);

if (likely(req))
diff --git a/include/crypto/kpp.h b/include/crypto/kpp.h
index 1988e24a0d1d..b4622bb747f9 100644
--- a/include/crypto/kpp.h
+++ b/include/crypto/kpp.h
@@ -201,7 +201,7 @@ static inline struct kpp_request *kpp_request_alloc(struct crypto_kpp *tfm,
{
struct kpp_request *req;

- req = kmalloc(sizeof(*req) + crypto_kpp_reqsize(tfm), gfp);
+ req = kzalloc(sizeof(*req) + crypto_kpp_reqsize(tfm), gfp);
if (likely(req))
kpp_request_set_tfm(req, tfm);

diff --git a/include/crypto/skcipher.h b/include/crypto/skcipher.h
index 080d1ba3611d..a35e6e6221e1 100644
--- a/include/crypto/skcipher.h
+++ b/include/crypto/skcipher.h
@@ -521,7 +521,7 @@ static inline struct skcipher_request *skcipher_request_alloc(
{
struct skcipher_request *req;

- req = kmalloc(sizeof(struct skcipher_request) +
+ req = kzalloc(sizeof(struct skcipher_request) +
crypto_skcipher_reqsize(tfm), gfp);

if (likely(req))
--
2.17.1