diff mbox series

crypto: fix memdup.cocci warnings

Message ID alpine.DEB.2.21.1911010953590.2883@hadrien (mailing list archive)
State New, archived
Headers show
Series crypto: fix memdup.cocci warnings | expand

Commit Message

Julia Lawall Nov. 1, 2019, 8:55 a.m. UTC
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(-)

Comments

Corentin Labbe Nov. 1, 2019, 12:52 p.m. UTC | #1
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
Herbert Xu Nov. 8, 2019, 3:20 p.m. UTC | #2
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.
diff mbox series

Patch

--- 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);