diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2015-04-09 05:40:35 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-04-10 09:39:24 -0400 |
commit | e9b8e5beb7befe682f9fe90428ea534b01d66568 (patch) | |
tree | f3592cb3e6f31960257ca0e83765241eef219adb | |
parent | 1711045fb11b4aa9afda066ce5fe68b2345d52c5 (diff) |
crypto: api - Move alg ref count init to crypto_check_alg
We currently initialise the crypto_alg ref count in the function
__crypto_register_alg. As one of the callers of that function
crypto_register_instance needs to obtain a ref count before it
calls __crypto_register_alg, we need to move the initialisation
out of there.
Since both callers of __crypto_register_alg call crypto_check_alg,
this is the logical place to perform the initialisation.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Acked-by: Stephan Mueller <smueller@chronox.de>
-rw-r--r-- | crypto/algapi.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c index f1d0307b1d08..1462c68492ea 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c | |||
@@ -64,6 +64,8 @@ static int crypto_check_alg(struct crypto_alg *alg) | |||
64 | if (alg->cra_priority < 0) | 64 | if (alg->cra_priority < 0) |
65 | return -EINVAL; | 65 | return -EINVAL; |
66 | 66 | ||
67 | atomic_set(&alg->cra_refcnt, 1); | ||
68 | |||
67 | return crypto_set_driver_name(alg); | 69 | return crypto_set_driver_name(alg); |
68 | } | 70 | } |
69 | 71 | ||
@@ -187,7 +189,6 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg) | |||
187 | 189 | ||
188 | ret = -EEXIST; | 190 | ret = -EEXIST; |
189 | 191 | ||
190 | atomic_set(&alg->cra_refcnt, 1); | ||
191 | list_for_each_entry(q, &crypto_alg_list, cra_list) { | 192 | list_for_each_entry(q, &crypto_alg_list, cra_list) { |
192 | if (q == alg) | 193 | if (q == alg) |
193 | goto err; | 194 | goto err; |