summaryrefslogtreecommitdiff
path: root/crypto/algapi.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2020-01-02 19:58:41 -0800
committerHerbert Xu <herbert@gondor.apana.org.au>2020-01-09 11:30:53 +0800
commite7d96e1eba38ccf867353d058e16738cdc226ced (patch)
tree7b628d48071ded1b3af39e1fba823db739acee6e /crypto/algapi.c
parentb95cf6f603b44edc703565e4cc331de93fda3ca4 (diff)
downloadlinux-crypto-e7d96e1eba38ccf867353d058e16738cdc226ced.tar.gz
linux-crypto-e7d96e1eba38ccf867353d058e16738cdc226ced.zip
crypto: algapi - make crypto_drop_spawn() a no-op on uninitialized spawns
Make crypto_drop_spawn() do nothing when the spawn hasn't been initialized with an algorithm yet. This will allow simplifying error handling in all the template ->create() functions, since on error they will be able to just call their usual "free instance" function, rather than having to handle dropping just the spawns that have been initialized so far. This does assume the spawn starts out zero-filled, but that's always the case since instances are allocated with kzalloc(). And some other code already assumes this anyway. 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 36384998..4c761f48 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -734,6 +734,9 @@ EXPORT_SYMBOL_GPL(crypto_grab_spawn);
void crypto_drop_spawn(struct crypto_spawn *spawn)
{
+ if (!spawn->alg) /* not yet initialized? */
+ return;
+
down_write(&crypto_alg_sem);
if (!spawn->dead)
list_del(&spawn->list);