crypto: amlogic - Use kmemdup in meson_aes_setkey()
authorYueHaibing <yuehaibing@huawei.com>
Tue, 29 Oct 2019 01:55:23 +0000 (01:55 +0000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 8 Nov 2019 15:00:46 +0000 (23:00 +0800)
Use kmemdup rather than duplicating its implementation

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Corentin Labbe <clabbe@baylibre.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/amlogic/amlogic-gxl-cipher.c

index e9283ff..78e776c 100644 (file)
@@ -372,10 +372,9 @@ int meson_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);
 
        return crypto_sync_skcipher_setkey(op->fallback_tfm, key, keylen);
 }