diff options
Diffstat (limited to 'crypto/algapi.c')
| -rw-r--r-- | crypto/algapi.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c index e604d0d8b7b4..37de377719ae 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -244,6 +244,7 @@ EXPORT_SYMBOL_GPL(crypto_remove_spawns); static void crypto_alg_finish_registration(struct crypto_alg *alg, struct list_head *algs_to_put) + __must_hold(&crypto_alg_sem) { struct crypto_alg *q; @@ -299,6 +300,7 @@ static struct crypto_larval *crypto_alloc_test_larval(struct crypto_alg *alg) static struct crypto_larval * __crypto_register_alg(struct crypto_alg *alg, struct list_head *algs_to_put) + __must_hold(&crypto_alg_sem) { struct crypto_alg *q; struct crypto_larval *larval; @@ -511,17 +513,13 @@ int crypto_register_algs(struct crypto_alg *algs, int count) for (i = 0; i < count; i++) { ret = crypto_register_alg(&algs[i]); - if (ret) - goto err; + if (ret) { + crypto_unregister_algs(algs, i); + return ret; + } } return 0; - -err: - for (--i; i >= 0; --i) - crypto_unregister_alg(&algs[i]); - - return ret; } EXPORT_SYMBOL_GPL(crypto_register_algs); @@ -529,7 +527,7 @@ void crypto_unregister_algs(struct crypto_alg *algs, int count) { int i; - for (i = 0; i < count; i++) + for (i = count - 1; i >= 0; --i) crypto_unregister_alg(&algs[i]); } EXPORT_SYMBOL_GPL(crypto_unregister_algs); |
