Commit 712d8069 authored by Denis Efremov's avatar Denis Efremov Committed by Herbert Xu

crypto: sun8i-ce - use kfree_sensitive()

Use kfree_sensitive() instead of open-coding it.
Signed-off-by: default avatarDenis Efremov <efremov@linux.com>
Acked-by: default avatarCorentin Labbe <clabbe.montjoie@gmail.com>
Tested-by: default avatarCorentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent ba42fa77
...@@ -366,10 +366,7 @@ void sun8i_ce_cipher_exit(struct crypto_tfm *tfm) ...@@ -366,10 +366,7 @@ void sun8i_ce_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_suspend(op->ce->dev); pm_runtime_put_sync_suspend(op->ce->dev);
} }
...@@ -391,10 +388,7 @@ int sun8i_ce_aes_setkey(struct crypto_skcipher *tfm, const u8 *key, ...@@ -391,10 +388,7 @@ int sun8i_ce_aes_setkey(struct crypto_skcipher *tfm, const u8 *key,
dev_dbg(ce->dev, "ERROR: Invalid keylen %u\n", keylen); dev_dbg(ce->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)
...@@ -416,10 +410,7 @@ int sun8i_ce_des3_setkey(struct crypto_skcipher *tfm, const u8 *key, ...@@ -416,10 +410,7 @@ int sun8i_ce_des3_setkey(struct crypto_skcipher *tfm, const u8 *key,
if (err) if (err)
return err; return err;
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)
......
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