Skip to content

Commit ede1328

Browse files
evdenisherbertx
authored andcommitted
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>
1 parent 712d806 commit ede1328

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

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

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

371-
if (op->key) {
372-
memzero_explicit(op->key, op->keylen);
373-
kfree(op->key);
374-
}
371+
kfree_sensitive(op->key);
375372
crypto_free_skcipher(op->fallback_tfm);
376373
pm_runtime_put_sync(op->ss->dev);
377374
}
@@ -393,10 +390,7 @@ int sun8i_ss_aes_setkey(struct crypto_skcipher *tfm, const u8 *key,
393390
dev_dbg(ss->dev, "ERROR: Invalid keylen %u\n", keylen);
394391
return -EINVAL;
395392
}
396-
if (op->key) {
397-
memzero_explicit(op->key, op->keylen);
398-
kfree(op->key);
399-
}
393+
kfree_sensitive(op->key);
400394
op->keylen = keylen;
401395
op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA);
402396
if (!op->key)
@@ -419,10 +413,7 @@ int sun8i_ss_des3_setkey(struct crypto_skcipher *tfm, const u8 *key,
419413
return -EINVAL;
420414
}
421415

422-
if (op->key) {
423-
memzero_explicit(op->key, op->keylen);
424-
kfree(op->key);
425-
}
416+
kfree_sensitive(op->key);
426417
op->keylen = keylen;
427418
op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA);
428419
if (!op->key)

0 commit comments

Comments
 (0)