Skip to content

Commit 44eff4a

Browse files
intel-lab-lkpherbertx
authored andcommitted
crypto: sun8i-ss - fix memdup.cocci warnings
Use kmemdup rather than duplicating its implementation Generated by: scripts/coccinelle/api/memdup.cocci Fixes: f08fcce ("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>
1 parent 09b6816 commit 44eff4a

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

‎drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,9 @@ int sun8i_ss_aes_setkey(struct crypto_skcipher *tfm, const u8 *key,
398398
kfree(op->key);
399399
}
400400
op->keylen = keylen;
401-
op->key = kmalloc(keylen, GFP_KERNEL | GFP_DMA);
401+
op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA);
402402
if (!op->key)
403403
return -ENOMEM;
404-
memcpy(op->key, key, keylen);
405404

406405
crypto_sync_skcipher_clear_flags(op->fallback_tfm, CRYPTO_TFM_REQ_MASK);
407406
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,
426425
kfree(op->key);
427426
}
428427
op->keylen = keylen;
429-
op->key = kmalloc(keylen, GFP_KERNEL | GFP_DMA);
428+
op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA);
430429
if (!op->key)
431430
return -ENOMEM;
432-
memcpy(op->key, key, keylen);
433431

434432
crypto_sync_skcipher_clear_flags(op->fallback_tfm, CRYPTO_TFM_REQ_MASK);
435433
crypto_sync_skcipher_set_flags(op->fallback_tfm, tfm->base.crt_flags & CRYPTO_TFM_REQ_MASK);

0 commit comments

Comments
 (0)