aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/api.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/api.c')
-rw-r--r--crypto/api.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/crypto/api.c b/crypto/api.c
index 80bba637fba7..8145310d7985 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -188,13 +188,16 @@ struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
188 if (crypto_init_flags(tfm, flags)) 188 if (crypto_init_flags(tfm, flags))
189 goto out_free_tfm; 189 goto out_free_tfm;
190 190
191 if (crypto_init_ops(tfm)) { 191 if (crypto_init_ops(tfm))
192 crypto_exit_ops(tfm);
193 goto out_free_tfm; 192 goto out_free_tfm;
194 } 193
194 if (alg->cra_init && alg->cra_init(tfm))
195 goto cra_init_failed;
195 196
196 goto out; 197 goto out;
197 198
199cra_init_failed:
200 crypto_exit_ops(tfm);
198out_free_tfm: 201out_free_tfm:
199 kfree(tfm); 202 kfree(tfm);
200 tfm = NULL; 203 tfm = NULL;
@@ -215,6 +218,8 @@ void crypto_free_tfm(struct crypto_tfm *tfm)
215 alg = tfm->__crt_alg; 218 alg = tfm->__crt_alg;
216 size = sizeof(*tfm) + alg->cra_ctxsize; 219 size = sizeof(*tfm) + alg->cra_ctxsize;
217 220
221 if (alg->cra_exit)
222 alg->cra_exit(tfm);
218 crypto_exit_ops(tfm); 223 crypto_exit_ops(tfm);
219 crypto_alg_put(alg); 224 crypto_alg_put(alg);
220 memset(tfm, 0, size); 225 memset(tfm, 0, size);