Skip to content

Commit 712d806

Browse files
evdenisherbertx
authored andcommitted
crypto: sun8i-ce - 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>
1 parent ba42fa7 commit 712d806

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

‎drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c‎

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,7 @@ void sun8i_ce_cipher_exit(struct crypto_tfm *tfm)
366366
{
367367
struct sun8i_cipher_tfm_ctx *op = crypto_tfm_ctx(tfm);
368368

369-
if (op->key) {
370-
memzero_explicit(op->key, op->keylen);
371-
kfree(op->key);
372-
}
369+
kfree_sensitive(op->key);
373370
crypto_free_skcipher(op->fallback_tfm);
374371
pm_runtime_put_sync_suspend(op->ce->dev);
375372
}
@@ -391,10 +388,7 @@ int sun8i_ce_aes_setkey(struct crypto_skcipher *tfm, const u8 *key,
391388
dev_dbg(ce->dev, "ERROR: Invalid keylen %u\n", keylen);
392389
return -EINVAL;
393390
}
394-
if (op->key) {
395-
memzero_explicit(op->key, op->keylen);
396-
kfree(op->key);
397-
}
391+
kfree_sensitive(op->key);
398392
op->keylen = keylen;
399393
op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA);
400394
if (!op->key)
@@ -416,10 +410,7 @@ int sun8i_ce_des3_setkey(struct crypto_skcipher *tfm, const u8 *key,
416410
if (err)
417411
return err;
418412

419-
if (op->key) {
420-
memzero_explicit(op->key, op->keylen);
421-
kfree(op->key);
422-
}
413+
kfree_sensitive(op->key);
423414
op->keylen = keylen;
424415
op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA);
425416
if (!op->key)

0 commit comments

Comments
 (0)