diff mbox

crypto: fix memdup.cocci warnings

Message ID 20180215164013.GA107126@lkp-hsx02 (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show

Commit Message

Fengguang Wu Feb. 15, 2018, 4:40 p.m. UTC
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(-)

Comments

Herbert Xu Feb. 22, 2018, 3:14 p.m. UTC | #1
On Fri, Feb 16, 2018 at 12:40:13AM +0800, kbuild test robot wrote:
> 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>

Patch applied.  Thanks.
diff mbox

Patch

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