]> git.baikalelectronics.ru Git - kernel.git/commitdiff
crypto: sun8i-ss - fix memdup.cocci warnings
authorkbuild test robot <lkp@intel.com>
Fri, 1 Nov 2019 08:55:34 +0000 (09:55 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 8 Nov 2019 15:15:52 +0000 (23:15 +0800)
Use kmemdup rather than duplicating its implementation

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

Fixes: da6d15b4f8cc ("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>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c

index 349cce39c25741732877459bf6d65b27745150a0..f222979a562329041c3b3b3a6d5f19152c1f41bd 100644 (file)
@@ -398,10 +398,9 @@ int sun8i_ss_aes_setkey(struct crypto_skcipher *tfm, const u8 *key,
                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_skcipher *tfm, const u8 *key,
                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);