From: Herbert Xu Date: Wed, 8 Jul 2015 23:17:17 +0000 (+0800) Subject: crypto: aead - Add type-safe function for freeing instances X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ba75e15fa0c4db489ed0d0a9745f904a7d5e19cc;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git crypto: aead - Add type-safe function for freeing instances This patch adds a type-safe function for freeing AEAD instances to struct aead_instance. This replaces the existing free function in struct crypto_template which does not know the type of the instance that it's freeing. Signed-off-by: Herbert Xu --- diff --git a/crypto/aead.c b/crypto/aead.c index 07bf99773548..8cd45a7eb7af 100644 --- a/crypto/aead.c +++ b/crypto/aead.c @@ -307,9 +307,22 @@ static void crypto_aead_show(struct seq_file *m, struct crypto_alg *alg) seq_printf(m, "geniv : \n"); } +static void crypto_aead_free_instance(struct crypto_instance *inst) +{ + struct aead_instance *aead = aead_instance(inst); + + if (!aead->free) { + inst->tmpl->free(inst); + return; + } + + aead->free(aead); +} + static const struct crypto_type crypto_new_aead_type = { .extsize = crypto_alg_extsize, .init_tfm = crypto_aead_init_tfm, + .free = crypto_aead_free_instance, #ifdef CONFIG_PROC_FS .show = crypto_aead_show, #endif diff --git a/include/crypto/internal/aead.h b/include/crypto/internal/aead.h index c3942f4d6e9f..a292e960fb33 100644 --- a/include/crypto/internal/aead.h +++ b/include/crypto/internal/aead.h @@ -21,6 +21,7 @@ struct rtattr; struct aead_instance { + void (*free)(struct aead_instance *inst); union { struct { char head[offsetof(struct aead_alg, base)];