Skip to content

Commit e9b8e5b

Browse files
committed
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 <[email protected]> Acked-by: Stephan Mueller <[email protected]>
1 parent 1711045 commit e9b8e5b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

crypto/algapi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ static int crypto_check_alg(struct crypto_alg *alg)
6464
if (alg->cra_priority < 0)
6565
return -EINVAL;
6666

67+
atomic_set(&alg->cra_refcnt, 1);
68+
6769
return crypto_set_driver_name(alg);
6870
}
6971

@@ -187,7 +189,6 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg)
187189

188190
ret = -EEXIST;
189191

190-
atomic_set(&alg->cra_refcnt, 1);
191192
list_for_each_entry(q, &crypto_alg_list, cra_list) {
192193
if (q == alg)
193194
goto err;

0 commit comments

Comments
 (0)