crypto: api - Move alg ref count init to crypto_check_alg
[firefly-linux-kernel-4.4.55.git] / crypto / algapi.c
index f1d0307b1d083f3e374dbb2db4bce45a0f483948..1462c68492ea3edb1adb29cdc760f117f97b046b 100644 (file)
@@ -64,6 +64,8 @@ static int crypto_check_alg(struct crypto_alg *alg)
        if (alg->cra_priority < 0)
                return -EINVAL;
 
+       atomic_set(&alg->cra_refcnt, 1);
+
        return crypto_set_driver_name(alg);
 }
 
@@ -187,7 +189,6 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg)
 
        ret = -EEXIST;
 
-       atomic_set(&alg->cra_refcnt, 1);
        list_for_each_entry(q, &crypto_alg_list, cra_list) {
                if (q == alg)
                        goto err;