summaryrefslogtreecommitdiffstats
path: root/crypto/shash.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2020-01-03 05:04:35 +0100
committerHerbert Xu <herbert@gondor.apana.org.au>2020-01-09 04:30:57 +0100
commit48fb3e5785be7ef69a43c04f617a1c05000ee2d0 (patch)
treebfff2c6e847f25d451b842ce269bd795104681ed /crypto/shash.c
parentcrypto: algapi - fold crypto_init_spawn() into crypto_grab_spawn() (diff)
downloadlinux-48fb3e5785be7ef69a43c04f617a1c05000ee2d0.tar.xz
linux-48fb3e5785be7ef69a43c04f617a1c05000ee2d0.zip
crypto: hash - add support for new way of freeing instances
Add support to shash and ahash for the new way of freeing instances (already used for skcipher, aead, and akcipher) where a ->free() method is installed to the instance struct itself. These methods are more strongly-typed than crypto_template::free(), which they replace. This will allow removing support for the old way of freeing instances. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/shash.c')
-rw-r--r--crypto/shash.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/crypto/shash.c b/crypto/shash.c
index 4d6ccb59e126..2f6adb49727b 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -423,6 +423,18 @@ static int crypto_shash_init_tfm(struct crypto_tfm *tfm)
return 0;
}
+static void crypto_shash_free_instance(struct crypto_instance *inst)
+{
+ struct shash_instance *shash = shash_instance(inst);
+
+ if (!shash->free) {
+ inst->tmpl->free(inst);
+ return;
+ }
+
+ shash->free(shash);
+}
+
#ifdef CONFIG_NET
static int crypto_shash_report(struct sk_buff *skb, struct crypto_alg *alg)
{
@@ -459,6 +471,7 @@ static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg)
static const struct crypto_type crypto_shash_type = {
.extsize = crypto_alg_extsize,
.init_tfm = crypto_shash_init_tfm,
+ .free = crypto_shash_free_instance,
#ifdef CONFIG_PROC_FS
.show = crypto_shash_show,
#endif