crypto: sun8i-ss - use kfree_sensitive()
Use kfree_sensitive() instead of open-coding it. Signed-off-by: Denis Efremov <efremov@linux.com> Acked-by: Corentin Labbe <clabbe.montjoie@gmail.com> Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
712d806957
commit
ede13285bb
|
@ -368,10 +368,7 @@ void sun8i_ss_cipher_exit(struct crypto_tfm *tfm)
|
||||||
{
|
{
|
||||||
struct sun8i_cipher_tfm_ctx *op = crypto_tfm_ctx(tfm);
|
struct sun8i_cipher_tfm_ctx *op = crypto_tfm_ctx(tfm);
|
||||||
|
|
||||||
if (op->key) {
|
kfree_sensitive(op->key);
|
||||||
memzero_explicit(op->key, op->keylen);
|
|
||||||
kfree(op->key);
|
|
||||||
}
|
|
||||||
crypto_free_skcipher(op->fallback_tfm);
|
crypto_free_skcipher(op->fallback_tfm);
|
||||||
pm_runtime_put_sync(op->ss->dev);
|
pm_runtime_put_sync(op->ss->dev);
|
||||||
}
|
}
|
||||||
|
@ -393,10 +390,7 @@ int sun8i_ss_aes_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||||
dev_dbg(ss->dev, "ERROR: Invalid keylen %u\n", keylen);
|
dev_dbg(ss->dev, "ERROR: Invalid keylen %u\n", keylen);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (op->key) {
|
kfree_sensitive(op->key);
|
||||||
memzero_explicit(op->key, op->keylen);
|
|
||||||
kfree(op->key);
|
|
||||||
}
|
|
||||||
op->keylen = keylen;
|
op->keylen = keylen;
|
||||||
op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA);
|
op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA);
|
||||||
if (!op->key)
|
if (!op->key)
|
||||||
|
@ -419,10 +413,7 @@ int sun8i_ss_des3_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (op->key) {
|
kfree_sensitive(op->key);
|
||||||
memzero_explicit(op->key, op->keylen);
|
|
||||||
kfree(op->key);
|
|
||||||
}
|
|
||||||
op->keylen = keylen;
|
op->keylen = keylen;
|
||||||
op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA);
|
op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA);
|
||||||
if (!op->key)
|
if (!op->key)
|
||||||
|
|
Loading…
Reference in New Issue