Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba75e15f authored by Herbert Xu's avatar Herbert Xu
Browse files

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: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 319382a6
Loading
Loading
Loading
Loading
+13 −0
Original line number Original line Diff line number Diff line
@@ -307,9 +307,22 @@ static void crypto_aead_show(struct seq_file *m, struct crypto_alg *alg)
	seq_printf(m, "geniv        : <none>\n");
	seq_printf(m, "geniv        : <none>\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 = {
static const struct crypto_type crypto_new_aead_type = {
	.extsize = crypto_alg_extsize,
	.extsize = crypto_alg_extsize,
	.init_tfm = crypto_aead_init_tfm,
	.init_tfm = crypto_aead_init_tfm,
	.free = crypto_aead_free_instance,
#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS
	.show = crypto_aead_show,
	.show = crypto_aead_show,
#endif
#endif
+1 −0
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@
struct rtattr;
struct rtattr;


struct aead_instance {
struct aead_instance {
	void (*free)(struct aead_instance *inst);
	union {
	union {
		struct {
		struct {
			char head[offsetof(struct aead_alg, base)];
			char head[offsetof(struct aead_alg, base)];