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 | d4fdc2dfaa755e0bf22de6a2774cac2e5ae45cf4 (patch) | |
tree | 18c2e44d234eaff00fbb2b9ae243d4ea69619651 /crypto/skcipher.c | |
parent | a24a1fd731274ebbca873000e2c7fbe8224ae4c8 (diff) | |
download | linux-d4fdc2dfaa755e0bf22de6a2774cac2e5ae45cf4.tar.bz2 |
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/skcipher.c')
-rw-r--r-- | crypto/skcipher.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/crypto/skcipher.c b/crypto/skcipher.c index 42add1e0814f..7221def7b9a7 100644 --- a/crypto/skcipher.c +++ b/crypto/skcipher.c @@ -865,6 +865,9 @@ int skcipher_register_instance(struct crypto_template *tmpl, { int err; + if (WARN_ON(!inst->free)) + return -EINVAL; + err = skcipher_prepare_alg(&inst->alg); if (err) return err; |