diff mbox series

crypto: sun8i-ss - use kfree_sensitive()

Message ID 20200826132451.398651-1-efremov@linux.com
State Accepted
Commit ede13285bb122dd9958eb9a0c128b074b22c8f36
Headers show
Series crypto: sun8i-ss - use kfree_sensitive() | expand

Commit Message

Denis Efremov Aug. 26, 2020, 1:24 p.m. UTC
Use kfree_sensitive() instead of open-coding it.

Signed-off-by: Denis Efremov <efremov@linux.com>
---
 drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c
index 7b39b4495571..49d89b31eb6b 100644
--- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c
+++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c
@@ -369,8 +369,7 @@  void sun8i_ss_cipher_exit(struct crypto_tfm *tfm)
 	struct sun8i_cipher_tfm_ctx *op = crypto_tfm_ctx(tfm);
 
 	if (op->key) {
-		memzero_explicit(op->key, op->keylen);
-		kfree(op->key);
+		kfree_sensitive(op->key);
 	}
 	crypto_free_skcipher(op->fallback_tfm);
 	pm_runtime_put_sync(op->ss->dev);
@@ -394,8 +393,7 @@  int sun8i_ss_aes_setkey(struct crypto_skcipher *tfm, const u8 *key,
 		return -EINVAL;
 	}
 	if (op->key) {
-		memzero_explicit(op->key, op->keylen);
-		kfree(op->key);
+		kfree_sensitive(op->key);
 	}
 	op->keylen = keylen;
 	op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA);
@@ -420,8 +418,7 @@  int sun8i_ss_des3_setkey(struct crypto_skcipher *tfm, const u8 *key,
 	}
 
 	if (op->key) {
-		memzero_explicit(op->key, op->keylen);
-		kfree(op->key);
+		kfree_sensitive(op->key);
 	}
 	op->keylen = keylen;
 	op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA);