aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/api.c13
-rw-r--r--include/crypto/algapi.h1
-rw-r--r--include/linux/crypto.h2
3 files changed, 8 insertions, 8 deletions
diff --git a/crypto/api.c b/crypto/api.c
index 0444d242e985..cbaaf346ad13 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -300,8 +300,8 @@ static void crypto_exit_ops(struct crypto_tfm *tfm)
300 const struct crypto_type *type = tfm->__crt_alg->cra_type; 300 const struct crypto_type *type = tfm->__crt_alg->cra_type;
301 301
302 if (type) { 302 if (type) {
303 if (type->exit) 303 if (tfm->exit)
304 type->exit(tfm); 304 tfm->exit(tfm);
305 return; 305 return;
306 } 306 }
307 307
@@ -379,17 +379,16 @@ struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
379 if (err) 379 if (err)
380 goto out_free_tfm; 380 goto out_free_tfm;
381 381
382 if (alg->cra_init && (err = alg->cra_init(tfm))) { 382 if (!tfm->exit && alg->cra_init && (err = alg->cra_init(tfm)))
383 if (err == -EAGAIN)
384 crypto_shoot_alg(alg);
385 goto cra_init_failed; 383 goto cra_init_failed;
386 }
387 384
388 goto out; 385 goto out;
389 386
390cra_init_failed: 387cra_init_failed:
391 crypto_exit_ops(tfm); 388 crypto_exit_ops(tfm);
392out_free_tfm: 389out_free_tfm:
390 if (err == -EAGAIN)
391 crypto_shoot_alg(alg);
393 kfree(tfm); 392 kfree(tfm);
394out_err: 393out_err:
395 tfm = ERR_PTR(err); 394 tfm = ERR_PTR(err);
@@ -469,7 +468,7 @@ void crypto_free_tfm(struct crypto_tfm *tfm)
469 alg = tfm->__crt_alg; 468 alg = tfm->__crt_alg;
470 size = sizeof(*tfm) + alg->cra_ctxsize; 469 size = sizeof(*tfm) + alg->cra_ctxsize;
471 470
472 if (alg->cra_exit) 471 if (!tfm->exit && alg->cra_exit)
473 alg->cra_exit(tfm); 472 alg->cra_exit(tfm);
474 crypto_exit_ops(tfm); 473 crypto_exit_ops(tfm);
475 crypto_mod_put(alg); 474 crypto_mod_put(alg);
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
index 60d06e784be3..5fb6d8618d4d 100644
--- a/include/crypto/algapi.h
+++ b/include/crypto/algapi.h
@@ -23,7 +23,6 @@ struct seq_file;
23struct crypto_type { 23struct crypto_type {
24 unsigned int (*ctxsize)(struct crypto_alg *alg, u32 type, u32 mask); 24 unsigned int (*ctxsize)(struct crypto_alg *alg, u32 type, u32 mask);
25 int (*init)(struct crypto_tfm *tfm, u32 type, u32 mask); 25 int (*init)(struct crypto_tfm *tfm, u32 type, u32 mask);
26 void (*exit)(struct crypto_tfm *tfm);
27 void (*show)(struct seq_file *m, struct crypto_alg *alg); 26 void (*show)(struct seq_file *m, struct crypto_alg *alg);
28}; 27};
29 28
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index 3d2317e4af2e..ea52cd944fd9 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -480,6 +480,8 @@ struct crypto_tfm {
480 struct compress_tfm compress; 480 struct compress_tfm compress;
481 struct rng_tfm rng; 481 struct rng_tfm rng;
482 } crt_u; 482 } crt_u;
483
484 void (*exit)(struct crypto_tfm *tfm);
483 485
484 struct crypto_alg *__crt_alg; 486 struct crypto_alg *__crt_alg;
485 487