Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: api - Add cra_type->destroy hook

Add a cra_type->destroy hook so that resources can be freed after
the last user of a registered algorithm is gone.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+14 -2
+10
crypto/api.c
··· 707 707 } 708 708 EXPORT_SYMBOL_GPL(crypto_req_done); 709 709 710 + void crypto_destroy_alg(struct crypto_alg *alg) 711 + { 712 + if (alg->cra_type && alg->cra_type->destroy) 713 + alg->cra_type->destroy(alg); 714 + 715 + if (alg->cra_destroy) 716 + alg->cra_destroy(alg); 717 + } 718 + EXPORT_SYMBOL_GPL(crypto_destroy_alg); 719 + 710 720 MODULE_DESCRIPTION("Cryptographic core API"); 711 721 MODULE_LICENSE("GPL");
+4 -2
crypto/internal.h
··· 40 40 void (*show)(struct seq_file *m, struct crypto_alg *alg); 41 41 int (*report)(struct sk_buff *skb, struct crypto_alg *alg); 42 42 void (*free)(struct crypto_instance *inst); 43 + void (*destroy)(struct crypto_alg *alg); 43 44 44 45 unsigned int type; 45 46 unsigned int maskclear; ··· 128 127 const struct crypto_type *frontend, int node); 129 128 void *crypto_clone_tfm(const struct crypto_type *frontend, 130 129 struct crypto_tfm *otfm); 130 + void crypto_destroy_alg(struct crypto_alg *alg); 131 131 132 132 static inline void *crypto_create_tfm(struct crypto_alg *alg, 133 133 const struct crypto_type *frontend) ··· 165 163 166 164 static inline void crypto_alg_put(struct crypto_alg *alg) 167 165 { 168 - if (refcount_dec_and_test(&alg->cra_refcnt) && alg->cra_destroy) 169 - alg->cra_destroy(alg); 166 + if (refcount_dec_and_test(&alg->cra_refcnt)) 167 + crypto_destroy_alg(alg); 170 168 } 171 169 172 170 static inline int crypto_tmpl_get(struct crypto_template *tmpl)