Commit d832a612 authored by YueHaibing's avatar YueHaibing Committed by Herbert Xu

crypto: amlogic - Use kmemdup in meson_aes_setkey()

Use kmemdup rather than duplicating its implementation
Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
Acked-by: default avatarCorentin Labbe <clabbe@baylibre.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 427e6e3a
...@@ -372,10 +372,9 @@ int meson_aes_setkey(struct crypto_skcipher *tfm, const u8 *key, ...@@ -372,10 +372,9 @@ int meson_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);
return crypto_sync_skcipher_setkey(op->fallback_tfm, key, keylen); return crypto_sync_skcipher_setkey(op->fallback_tfm, key, keylen);
} }
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