summaryrefslogtreecommitdiff
path: root/crypto/shash.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2020-01-02 20:04:40 -0800
committerHerbert Xu <herbert@gondor.apana.org.au>2020-01-09 11:30:58 +0800
commit9f7dce4caaa7cf1f047f5944c6dce72f6c7f32a6 (patch)
treee7275c4599725567290cc55bd236aa3cf7da53b9 /crypto/shash.c
parent48c1a27b907ac975a8b22bbe87c03a8f8a6d5dc8 (diff)
downloadlinux-crypto-9f7dce4caaa7cf1f047f5944c6dce72f6c7f32a6.tar.gz
linux-crypto-9f7dce4caaa7cf1f047f5944c6dce72f6c7f32a6.zip
crypto: algapi - enforce that all instances have a ->free() method
All instances need to have a ->free() method, but people could forget to set it and then not notice if the instance is never unregistered. To help detect this bug earlier, don't allow an instance without a ->free() method to be registered, and complain loudly if someone tries to do it. 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.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/crypto/shash.c b/crypto/shash.c
index 70faf28b..c075b26c 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -577,6 +577,9 @@ int shash_register_instance(struct crypto_template *tmpl,
{
int err;
+ if (WARN_ON(!inst->free))
+ return -EINVAL;
+
err = shash_prepare_alg(&inst->alg);
if (err)
return err;