Commit 44eff4ad authored by kbuild test robot's avatar kbuild test robot Committed by Herbert Xu

crypto: sun8i-ss - fix memdup.cocci warnings

Use kmemdup rather than duplicating its implementation

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

Fixes: f08fcced ("crypto: allwinner - Add sun8i-ss cryptographic offloader")
CC: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: default avatarkbuild test robot <lkp@intel.com>
Signed-off-by: default avatarJulia Lawall <julia.lawall@lip6.fr>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 09b68164
...@@ -398,10 +398,9 @@ int sun8i_ss_aes_setkey(struct crypto_skcipher *tfm, const u8 *key, ...@@ -398,10 +398,9 @@ int sun8i_ss_aes_setkey(struct crypto_skcipher *tfm, const u8 *key,
kfree(op->key); kfree(op->key);
} }
op->keylen = keylen; op->keylen = keylen;
op->key = kmalloc(keylen, GFP_KERNEL | GFP_DMA); op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA);
if (!op->key) if (!op->key)
return -ENOMEM; return -ENOMEM;
memcpy(op->key, key, keylen);
crypto_sync_skcipher_clear_flags(op->fallback_tfm, CRYPTO_TFM_REQ_MASK); 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); 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, ...@@ -426,10 +425,9 @@ int sun8i_ss_des3_setkey(struct crypto_skcipher *tfm, const u8 *key,
kfree(op->key); kfree(op->key);
} }
op->keylen = keylen; op->keylen = keylen;
op->key = kmalloc(keylen, GFP_KERNEL | GFP_DMA); op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA);
if (!op->key) if (!op->key)
return -ENOMEM; return -ENOMEM;
memcpy(op->key, key, keylen);
crypto_sync_skcipher_clear_flags(op->fallback_tfm, CRYPTO_TFM_REQ_MASK); 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); crypto_sync_skcipher_set_flags(op->fallback_tfm, tfm->base.crt_flags & CRYPTO_TFM_REQ_MASK);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment