crypto: bcm - set memory to zero only once
PATCH RESEND 1/1 crypto: bcm - set memory to zero only once
Use kmalloc_array() instead of kcalloc() because sg_init_table() already sets the memory to zero. This avoids zeroing the memory twice.
--- drivers/crypto/bcm/cipher.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/crypto/bcm/cipher.c +12 -12
@@ -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 ;
Signature · 1 line
2.48.1
Herbert Xu
maintainerQuoted 7 lines · Thorsten Blum
Use
kmalloc_array()instead ofkcalloc()becausesg_init_table()already sets the memory to zero. This avoids zeroing the memory twice.Signed-off-by Thorsten Blum <[email protected]>--- 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,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 11 lines · Herbert Xu
Quoted 7 lines · Thorsten Blum
Use
kmalloc_array()instead ofkcalloc()becausesg_init_table()already sets the memory to zero. This avoids zeroing the memory twice.Signed-off-by Thorsten Blum <[email protected]>---
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