mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] crypto: all - alloc and init all req alloc as zero
@ 2023-07-27  8:05 Zhang Yiqun
  2023-07-27  8:07 ` Herbert Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Zhang Yiqun @ 2023-07-27  8:05 UTC (permalink / raw)
  To: herbert, davem; +Cc: linux-crypto, linux-kernel, Zhang Yiqun

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@phytium.com.cn>
---
 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


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

* Re: [PATCH] crypto: all - alloc and init all req alloc as zero
  2023-07-27  8:05 [PATCH] crypto: all - alloc and init all req alloc as zero Zhang Yiqun
@ 2023-07-27  8:07 ` Herbert Xu
  2023-07-28  9:06   ` 张轶群
  0 siblings, 1 reply; 3+ messages in thread
From: Herbert Xu @ 2023-07-27  8:07 UTC (permalink / raw)
  To: Zhang Yiqun; +Cc: davem, linux-crypto, linux-kernel

On Thu, Jul 27, 2023 at 04:05:48PM +0800, Zhang Yiqun wrote:
> 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@phytium.com.cn>
> ---
>  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(-)

Nack.  Unless you have a specific issue please don't submit vague
patches like this.  You should always state what issue led you to
make a change like this.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: Re: [PATCH] crypto: all - alloc and init all req alloc as zero
  2023-07-27  8:07 ` Herbert Xu
@ 2023-07-28  9:06   ` 张轶群
  0 siblings, 0 replies; 3+ messages in thread
From: 张轶群 @ 2023-07-28  9:06 UTC (permalink / raw)
  To: Herbert Xu; +Cc: davem, linux-crypto, linux-kernel

Actually, I met a problem in my own development. Because some members in req
struct is not intialized, they cause some errors in test. If we change kmalloc
to kzalloc, it can facilitate all developers to care about inialized all 
members. I hope my idea can convince you. But I think you have other
important consideration.

Thanks,

> -----Original Messages-----
> From: "Herbert Xu" <herbert@gondor.apana.org.au>
> Send time:Thursday, 07/27/2023 16:07:50
> To: "Zhang Yiqun" <zhangyiqun@phytium.com.cn>
> Cc: davem@davemloft.net, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] crypto: all - alloc and init all req alloc as zero
> 
> On Thu, Jul 27, 2023 at 04:05:48PM +0800, Zhang Yiqun wrote:
> > 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@phytium.com.cn>
> > ---
> >  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(-)
> 
> Nack.  Unless you have a specific issue please don't submit vague
> patches like this.  You should always state what issue led you to
> make a change like this.
> 
> Thanks,
> -- 
> Email: Herbert Xu <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt



信息安全声明:本邮件包含信息归发件人所在组织所有,发件人所在组织对该邮件拥有所有权利。请接收者注意保密,未经发件人书面许可,不得向任何第三方组织和个人透露本邮件所含信息。
Information Security Notice: The information contained in this mail is solely property of the sender's organization.This mail communication is confidential.Recipients named above are obligated to maintain secrecy and are not permitted to disclose the contents of this communication to others.

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-27  8:05 [PATCH] crypto: all - alloc and init all req alloc as zero Zhang Yiqun
2023-07-27  8:07 ` Herbert Xu
2023-07-28  9:06   ` 张轶群

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®