]> git.baikalelectronics.ru Git - kernel.git/commitdiff
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 e9283ffdbd233fec091e3b469b117f647471a939..78e776c5870536418cfa7eb6d101569139b25ca9 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);
 }