From ce6e9a2d0a62f4d590f6dc21833fd56dea5f50f5 Mon Sep 17 00:00:00 2001 From: Fengguang Wu Date: Fri, 16 Feb 2018 00:40:13 +0800 Subject: [PATCH] crypto: ccree - fix memdup.cocci warnings 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: 42039d9432b1 ("crypto: ccree - add skcipher support") CC: Gilad Ben-Yossef Signed-off-by: Fengguang Wu Signed-off-by: Herbert Xu --- drivers/crypto/ccree/cc_cipher.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c index 5760ca9481ead..1aa7c56dbc02b 100644 --- a/drivers/crypto/ccree/cc_cipher.c +++ b/drivers/crypto/ccree/cc_cipher.c @@ -626,12 +626,11 @@ static int cc_cipher_process(struct skcipher_request *req, /* 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) && -- 2.39.5