Linux-Crypto Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] crypto: fix memdup.cocci warnings
@ 2019-11-01  8:55 Julia Lawall
  2019-11-01 12:52 ` Corentin Labbe
  2019-11-08 15:20 ` Herbert Xu
  0 siblings, 2 replies; 4+ messages in thread
From: Julia Lawall @ 2019-11-01  8:55 UTC (permalink / raw)
  To: Corentin Labbe
  Cc: kbuild-all, linux-crypto, Herbert Xu, Maxime Ripard,
	Chen-Yu Tsai, linux-crypto, linux-arm-kernel, linux-kernel

From: kbuild test robot <lkp@intel.com>

Use kmemdup rather than duplicating its implementation

Generated by: scripts/coccinelle/api/memdup.cocci

Fixes: f08fcced6d00 ("crypto: allwinner - Add sun8i-ss cryptographic offloader")
CC: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
head:   298b4c604008025b134bc6fccbc4018449945d60
commit: f08fcced6d0017c39cb6eccb571290867119d049 [154/163] crypto: allwinner - Add sun8i-ss cryptographic offloader
:::::: branch date: 3 hours ago
:::::: commit date: 3 hours ago

Please take the patch only if it's a positive warning. Thanks!

 sun8i-ss-cipher.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

--- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c
+++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c
@@ -398,10 +398,9 @@ int sun8i_ss_aes_setkey(struct crypto_sk
 		kfree(op->key);
 	}
 	op->keylen = keylen;
-	op->key = kmalloc(keylen, GFP_KERNEL | GFP_DMA);
+	op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA);
 	if (!op->key)
 		return -ENOMEM;
-	memcpy(op->key, key, keylen);

 	crypto_sync_skcipher_clear_flags(op->fallback_tfm, CRYPTO_TFM_REQ_MASK);
 	crypto_sync_skcipher_set_flags(op->fallback_tfm, tfm->base.crt_flags & CRYPTO_TFM_REQ_MASK);
@@ -426,10 +425,9 @@ int sun8i_ss_des3_setkey(struct crypto_s
 		kfree(op->key);
 	}
 	op->keylen = keylen;
-	op->key = kmalloc(keylen, GFP_KERNEL | GFP_DMA);
+	op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA);
 	if (!op->key)
 		return -ENOMEM;
-	memcpy(op->key, key, keylen);

 	crypto_sync_skcipher_clear_flags(op->fallback_tfm, CRYPTO_TFM_REQ_MASK);
 	crypto_sync_skcipher_set_flags(op->fallback_tfm, tfm->base.crt_flags & CRYPTO_TFM_REQ_MASK);

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

* Re: [PATCH] crypto: fix memdup.cocci warnings
  2019-11-01  8:55 [PATCH] crypto: fix memdup.cocci warnings Julia Lawall
@ 2019-11-01 12:52 ` Corentin Labbe
  2019-11-08 15:20 ` Herbert Xu
  1 sibling, 0 replies; 4+ messages in thread
From: Corentin Labbe @ 2019-11-01 12:52 UTC (permalink / raw)
  To: Julia Lawall
  Cc: kbuild-all, linux-crypto, Herbert Xu, Maxime Ripard,
	Chen-Yu Tsai, linux-arm-kernel, linux-kernel

On Fri, Nov 01, 2019 at 09:55:34AM +0100, Julia Lawall wrote:
> From: kbuild test robot <lkp@intel.com>
> 
> Use kmemdup rather than duplicating its implementation
> 
> Generated by: scripts/coccinelle/api/memdup.cocci
> 
> Fixes: f08fcced6d00 ("crypto: allwinner - Add sun8i-ss cryptographic offloader")
> CC: Corentin Labbe <clabbe.montjoie@gmail.com>
> Signed-off-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
> ---

Corentin Labbe <clabbe.montjoie@gmail.com>

Thanks

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

* Re: [PATCH] crypto: fix memdup.cocci warnings
  2019-11-01  8:55 [PATCH] crypto: fix memdup.cocci warnings Julia Lawall
  2019-11-01 12:52 ` Corentin Labbe
@ 2019-11-08 15:20 ` Herbert Xu
  1 sibling, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2019-11-08 15:20 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Corentin Labbe, kbuild-all, linux-crypto, Maxime Ripard,
	Chen-Yu Tsai, linux-arm-kernel, linux-kernel

On Fri, Nov 01, 2019 at 09:55:34AM +0100, Julia Lawall wrote:
> From: kbuild test robot <lkp@intel.com>
> 
> Use kmemdup rather than duplicating its implementation
> 
> Generated by: scripts/coccinelle/api/memdup.cocci
> 
> Fixes: f08fcced6d00 ("crypto: allwinner - Add sun8i-ss cryptographic offloader")
> CC: Corentin Labbe <clabbe.montjoie@gmail.com>
> Signed-off-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
> ---
> 
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
> head:   298b4c604008025b134bc6fccbc4018449945d60
> commit: f08fcced6d0017c39cb6eccb571290867119d049 [154/163] crypto: allwinner - Add sun8i-ss cryptographic offloader
> :::::: branch date: 3 hours ago
> :::::: commit date: 3 hours ago
> 
> Please take the patch only if it's a positive warning. Thanks!
> 
>  sun8i-ss-cipher.c |    6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Patch applied.  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] 4+ messages in thread

* [PATCH] crypto: fix memdup.cocci warnings
  2018-02-15 16:40 [cryptodev:master 9/38] drivers/crypto/ccree/cc_cipher.c:629:15-22: WARNING opportunity for kmemdep kbuild test robot
@ 2018-02-15 16:40 ` kbuild test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2018-02-15 16:40 UTC (permalink / raw)
  To: Gilad Ben-Yossef; +Cc: kbuild-all, linux-crypto, Herbert Xu

From: Fengguang Wu <fengguang.wu@intel.com>

drivers/crypto/ccree/cc_cipher.c:629:15-22: WARNING opportunity for kmemdep

 Use kmemdup rather than duplicating its implementation

Generated by: scripts/coccinelle/api/memdup.cocci

Fixes: 63ee04c8b491 ("crypto: ccree - add skcipher support")
CC: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---

 cc_cipher.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/crypto/ccree/cc_cipher.c
+++ b/drivers/crypto/ccree/cc_cipher.c
@@ -626,12 +626,11 @@ static int cc_cipher_process(struct skci
 	/* The IV we are handed may be allocted from the stack so
 	 * we must copy it to a DMAable buffer before use.
 	 */
-	req_ctx->iv = kmalloc(ivsize, flags);
+	req_ctx->iv = kmemdup(iv, ivsize, flags);
 	if (!req_ctx->iv) {
 		rc = -ENOMEM;
 		goto exit_process;
 	}
-	memcpy(req_ctx->iv, iv, ivsize);
 
 	/*For CTS in case of data size aligned to 16 use CBC mode*/
 	if (((nbytes % AES_BLOCK_SIZE) == 0) &&

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

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-01  8:55 [PATCH] crypto: fix memdup.cocci warnings Julia Lawall
2019-11-01 12:52 ` Corentin Labbe
2019-11-08 15:20 ` Herbert Xu
  -- strict thread matches above, loose matches on Subject: below --
2018-02-15 16:40 [cryptodev:master 9/38] drivers/crypto/ccree/cc_cipher.c:629:15-22: WARNING opportunity for kmemdep kbuild test robot
2018-02-15 16:40 ` [PATCH] crypto: fix memdup.cocci warnings kbuild test robot

Linux-Crypto Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-crypto/0 linux-crypto/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-crypto linux-crypto/ https://lore.kernel.org/linux-crypto \
		linux-crypto@vger.kernel.org
	public-inbox-index linux-crypto

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-crypto


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git