summaryrefslogtreecommitdiff
path: root/crypto/algapi.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2019-01-06 12:46:06 -0800
committerHerbert Xu <herbert@gondor.apana.org.au>2019-01-11 14:16:58 +0800
commit81a913cde2c709d8322ae09a81d7064200ea56a9 (patch)
tree5064647fbc34de748db88011d73e34523dc815f0 /crypto/algapi.c
parent3937ac55f49305e0166a9059236951e06ec756fd (diff)
downloadlinux-crypto-81a913cde2c709d8322ae09a81d7064200ea56a9.tar.gz
linux-crypto-81a913cde2c709d8322ae09a81d7064200ea56a9.zip
crypto: algapi - reject NULL crypto_spawn::inst
It took me a while to notice the bug where the adiantum template left crypto_spawn::inst == NULL, because this only caused problems in certain cases where algorithms are dynamically loaded/unloaded. More improvements are needed, but for now make crypto_init_spawn() reject this case and WARN(), so this type of bug will be noticed immediately in the future. Note: I checked all callers and the adiantum template was the only place that had this wrong. So this WARN shouldn't trigger anymore. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/algapi.c')
-rw-r--r--crypto/algapi.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c
index f3d76631..713baabe 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -608,6 +608,9 @@ int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg,
{
int err = -EAGAIN;
+ if (WARN_ON_ONCE(inst == NULL))
+ return -EINVAL;
+
spawn->inst = inst;
spawn->mask = mask;