* [RESEND PATCH] crypto: bcm - set memory to zero only once
@ 2025-02-19 11:12 Thorsten Blum
2025-03-02 6:13 ` Herbert Xu
0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Blum @ 2025-02-19 11:12 UTC (permalink / raw)
To: Herbert Xu, David S. Miller, Chen Ridong, Uwe Kleine-König
Cc: Thorsten Blum, linux-crypto, linux-kernel
Use kmalloc_array() instead of kcalloc() because sg_init_table() already
sets the memory to zero. This avoids zeroing the memory twice.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/crypto/bcm/cipher.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
index 9e6798efbfb7..d4da2b5b595f 100644
--- a/drivers/crypto/bcm/cipher.c
+++ b/drivers/crypto/bcm/cipher.c
@@ -140,8 +140,8 @@ spu_skcipher_rx_sg_create(struct brcm_message *mssg,
struct iproc_ctx_s *ctx = rctx->ctx;
u32 datalen; /* Number of bytes of response data expected */
- mssg->spu.dst = kcalloc(rx_frag_num, sizeof(struct scatterlist),
- rctx->gfp);
+ mssg->spu.dst = kmalloc_array(rx_frag_num, sizeof(struct scatterlist),
+ rctx->gfp);
if (!mssg->spu.dst)
return -ENOMEM;
@@ -204,8 +204,8 @@ spu_skcipher_tx_sg_create(struct brcm_message *mssg,
u32 datalen; /* Number of bytes of response data expected */
u32 stat_len;
- mssg->spu.src = kcalloc(tx_frag_num, sizeof(struct scatterlist),
- rctx->gfp);
+ mssg->spu.src = kmalloc_array(tx_frag_num, sizeof(struct scatterlist),
+ rctx->gfp);
if (unlikely(!mssg->spu.src))
return -ENOMEM;
@@ -531,8 +531,8 @@ spu_ahash_rx_sg_create(struct brcm_message *mssg,
struct scatterlist *sg; /* used to build sgs in mbox message */
struct iproc_ctx_s *ctx = rctx->ctx;
- mssg->spu.dst = kcalloc(rx_frag_num, sizeof(struct scatterlist),
- rctx->gfp);
+ mssg->spu.dst = kmalloc_array(rx_frag_num, sizeof(struct scatterlist),
+ rctx->gfp);
if (!mssg->spu.dst)
return -ENOMEM;
@@ -586,8 +586,8 @@ spu_ahash_tx_sg_create(struct brcm_message *mssg,
u32 datalen; /* Number of bytes of response data expected */
u32 stat_len;
- mssg->spu.src = kcalloc(tx_frag_num, sizeof(struct scatterlist),
- rctx->gfp);
+ mssg->spu.src = kmalloc_array(tx_frag_num, sizeof(struct scatterlist),
+ rctx->gfp);
if (!mssg->spu.src)
return -ENOMEM;
@@ -1076,8 +1076,8 @@ static int spu_aead_rx_sg_create(struct brcm_message *mssg,
/* have to catch gcm pad in separate buffer */
rx_frag_num++;
- mssg->spu.dst = kcalloc(rx_frag_num, sizeof(struct scatterlist),
- rctx->gfp);
+ mssg->spu.dst = kmalloc_array(rx_frag_num, sizeof(struct scatterlist),
+ rctx->gfp);
if (!mssg->spu.dst)
return -ENOMEM;
@@ -1178,8 +1178,8 @@ static int spu_aead_tx_sg_create(struct brcm_message *mssg,
u32 assoc_offset = 0;
u32 stat_len;
- mssg->spu.src = kcalloc(tx_frag_num, sizeof(struct scatterlist),
- rctx->gfp);
+ mssg->spu.src = kmalloc_array(tx_frag_num, sizeof(struct scatterlist),
+ rctx->gfp);
if (!mssg->spu.src)
return -ENOMEM;
--
2.48.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RESEND PATCH] crypto: bcm - set memory to zero only once
2025-02-19 11:12 [RESEND PATCH] crypto: bcm - set memory to zero only once Thorsten Blum
@ 2025-03-02 6:13 ` Herbert Xu
2025-03-02 11:40 ` Thorsten Blum
0 siblings, 1 reply; 3+ messages in thread
From: Herbert Xu @ 2025-03-02 6:13 UTC (permalink / raw)
To: Thorsten Blum
Cc: David S. Miller, Chen Ridong, Uwe Kleine-König, linux-crypto,
linux-kernel
On Wed, Feb 19, 2025 at 12:12:53PM +0100, Thorsten Blum wrote:
> Use kmalloc_array() instead of kcalloc() because sg_init_table() already
> sets the memory to zero. This avoids zeroing the memory twice.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> drivers/crypto/bcm/cipher.c | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)
This patch has already been applied. Please check whether there
is any discrepancy between the applied version and this resend.
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: [RESEND PATCH] crypto: bcm - set memory to zero only once
2025-03-02 6:13 ` Herbert Xu
@ 2025-03-02 11:40 ` Thorsten Blum
0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Blum @ 2025-03-02 11:40 UTC (permalink / raw)
To: Herbert Xu
Cc: David S. Miller, Chen Ridong, Uwe Kleine-König, linux-crypto,
linux-kernel
On 2. Mar 2025, at 07:13, Herbert Xu wrote:
> On Wed, Feb 19, 2025 at 12:12:53PM +0100, Thorsten Blum wrote:
>> Use kmalloc_array() instead of kcalloc() because sg_init_table() already
>> sets the memory to zero. This avoids zeroing the memory twice.
>>
>> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
>> ---
>> drivers/crypto/bcm/cipher.c | 24 ++++++++++++------------
>> 1 file changed, 12 insertions(+), 12 deletions(-)
>
> This patch has already been applied. Please check whether there
> is any discrepancy between the applied version and this resend.
My bad, I must have missed it in -next. The patches are identical.
Thanks,
Thorsten
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-02 11:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-19 11:12 [RESEND PATCH] crypto: bcm - set memory to zero only once Thorsten Blum
2025-03-02 6:13 ` Herbert Xu
2025-03-02 11:40 ` Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).