static void crypto_free_instance(struct crypto_instance *inst)
{
- inst->alg.cra_type->free(inst);
+ struct crypto_alg *alg = &inst->alg;
+ const struct crypto_type *type;
+
+ type = alg->cra_type;
+ if (type->destroy)
+ type->destroy(alg);
+ type->free(inst);
}
static void crypto_destroy_instance_workfn(struct work_struct *w)
list_del_init(&inst->alg.cra_list);
hlist_del(&inst->list);
hlist_add_head(&inst->list, &tmpl->dead);
- inst->alg.cra_destroy = crypto_destroy_instance;
BUG_ON(!list_empty(&inst->alg.cra_users));
if (WARN_ON(refcount_read(&alg->cra_refcnt) != 1))
return;
- crypto_alg_put(alg);
+ if (alg->cra_type && alg->cra_type->destroy)
+ alg->cra_type->destroy(alg);
crypto_remove_final(&list);
}
inst->alg.cra_module = tmpl->module;
inst->alg.cra_flags |= CRYPTO_ALG_INSTANCE;
+ inst->alg.cra_destroy = crypto_destroy_instance;
down_write(&crypto_alg_sem);
}
EXPORT_SYMBOL_GPL(crypto_req_done);
-void crypto_destroy_alg(struct crypto_alg *alg)
-{
- if (alg->cra_type && alg->cra_type->destroy)
- alg->cra_type->destroy(alg);
-
- if (alg->cra_destroy)
- alg->cra_destroy(alg);
-}
-EXPORT_SYMBOL_GPL(crypto_destroy_alg);
-
MODULE_DESCRIPTION("Cryptographic core API");
MODULE_LICENSE("GPL");
const struct crypto_type *frontend, int node);
void *crypto_clone_tfm(const struct crypto_type *frontend,
struct crypto_tfm *otfm);
-void crypto_destroy_alg(struct crypto_alg *alg);
static inline void *crypto_create_tfm(struct crypto_alg *alg,
const struct crypto_type *frontend)
static inline void crypto_alg_put(struct crypto_alg *alg)
{
if (refcount_dec_and_test(&alg->cra_refcnt))
- crypto_destroy_alg(alg);
+ alg->cra_destroy(alg);
}
static inline int crypto_tmpl_get(struct crypto_template *tmpl)