|
@@ -67,12 +67,22 @@ static int crypto_check_alg(struct crypto_alg *alg)
|
|
return crypto_set_driver_name(alg);
|
|
return crypto_set_driver_name(alg);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static void crypto_free_instance(struct crypto_instance *inst)
|
|
|
|
+{
|
|
|
|
+ if (!inst->alg.cra_type->free) {
|
|
|
|
+ inst->tmpl->free(inst);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ inst->alg.cra_type->free(inst);
|
|
|
|
+}
|
|
|
|
+
|
|
static void crypto_destroy_instance(struct crypto_alg *alg)
|
|
static void crypto_destroy_instance(struct crypto_alg *alg)
|
|
{
|
|
{
|
|
struct crypto_instance *inst = (void *)alg;
|
|
struct crypto_instance *inst = (void *)alg;
|
|
struct crypto_template *tmpl = inst->tmpl;
|
|
struct crypto_template *tmpl = inst->tmpl;
|
|
|
|
|
|
- tmpl->free(inst);
|
|
|
|
|
|
+ crypto_free_instance(inst);
|
|
crypto_tmpl_put(tmpl);
|
|
crypto_tmpl_put(tmpl);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -481,7 +491,7 @@ void crypto_unregister_template(struct crypto_template *tmpl)
|
|
|
|
|
|
hlist_for_each_entry_safe(inst, n, list, list) {
|
|
hlist_for_each_entry_safe(inst, n, list, list) {
|
|
BUG_ON(atomic_read(&inst->alg.cra_refcnt) != 1);
|
|
BUG_ON(atomic_read(&inst->alg.cra_refcnt) != 1);
|
|
- tmpl->free(inst);
|
|
|
|
|
|
+ crypto_free_instance(inst);
|
|
}
|
|
}
|
|
crypto_remove_final(&users);
|
|
crypto_remove_final(&users);
|
|
}
|
|
}
|