crypto: api - Add cra_type->destroy hook

Add a cra_type->destroy hook so that resources can be freed after
the last user of a registered algorithm is gone.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Herbert Xu
2025-03-09 10:43:12 +08:00
parent 01894c8488
commit 3d6979bf3b
2 changed files with 14 additions and 2 deletions

View File

@@ -707,5 +707,15 @@ void crypto_req_done(void *data, int err)
}
EXPORT_SYMBOL_GPL(crypto_req_done);
void crypto_destroy_alg(struct crypto_alg *alg)
{
if (alg->cra_type && alg->cra_type->destroy)
alg->cra_type->destroy(alg);
if (alg->cra_destroy)
alg->cra_destroy(alg);
}
EXPORT_SYMBOL_GPL(crypto_destroy_alg);
MODULE_DESCRIPTION("Cryptographic core API");
MODULE_LICENSE("GPL");