Commit e9b8e5be authored by Herbert Xu's avatar Herbert Xu

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: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Acked-by: default avatarStephan Mueller <smueller@chronox.de>
parent 1711045f
...@@ -64,6 +64,8 @@ static int crypto_check_alg(struct crypto_alg *alg) ...@@ -64,6 +64,8 @@ static int crypto_check_alg(struct crypto_alg *alg)
if (alg->cra_priority < 0) if (alg->cra_priority < 0)
return -EINVAL; return -EINVAL;
atomic_set(&alg->cra_refcnt, 1);
return crypto_set_driver_name(alg); return crypto_set_driver_name(alg);
} }
...@@ -187,7 +189,6 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg) ...@@ -187,7 +189,6 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg)
ret = -EEXIST; ret = -EEXIST;
atomic_set(&alg->cra_refcnt, 1);
list_for_each_entry(q, &crypto_alg_list, cra_list) { list_for_each_entry(q, &crypto_alg_list, cra_list) {
if (q == alg) if (q == alg)
goto err; goto err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment