diff options
author | Eric Biggers <ebiggers@google.com> | 2020-01-02 20:04:40 -0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2020-01-09 11:30:58 +0800 |
commit | 9f7dce4caaa7cf1f047f5944c6dce72f6c7f32a6 (patch) | |
tree | e7275c4599725567290cc55bd236aa3cf7da53b9 /crypto/aead.c | |
parent | 48c1a27b907ac975a8b22bbe87c03a8f8a6d5dc8 (diff) | |
download | linux-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/aead.c')
-rw-r--r-- | crypto/aead.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/crypto/aead.c b/crypto/aead.c index 7707d322..16991095 100644 --- a/crypto/aead.c +++ b/crypto/aead.c @@ -288,6 +288,9 @@ int aead_register_instance(struct crypto_template *tmpl, { int err; + if (WARN_ON(!inst->free)) + return -EINVAL; + err = aead_prepare_alg(&inst->alg); if (err) return err; |