summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/api.c11
-rw-r--r--crypto/compress.c9
-rw-r--r--crypto/deflate.c4
3 files changed, 11 insertions, 13 deletions
diff --git a/crypto/api.c b/crypto/api.c
index 80bba637fba..8145310d798 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -188,13 +188,16 @@ struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
if (crypto_init_flags(tfm, flags))
goto out_free_tfm;
- if (crypto_init_ops(tfm)) {
- crypto_exit_ops(tfm);
+ if (crypto_init_ops(tfm))
goto out_free_tfm;
- }
+
+ if (alg->cra_init && alg->cra_init(tfm))
+ goto cra_init_failed;
goto out;
+cra_init_failed:
+ crypto_exit_ops(tfm);
out_free_tfm:
kfree(tfm);
tfm = NULL;
@@ -215,6 +218,8 @@ void crypto_free_tfm(struct crypto_tfm *tfm)
alg = tfm->__crt_alg;
size = sizeof(*tfm) + alg->cra_ctxsize;
+ if (alg->cra_exit)
+ alg->cra_exit(tfm);
crypto_exit_ops(tfm);
crypto_alg_put(alg);
memset(tfm, 0, size);
diff --git a/crypto/compress.c b/crypto/compress.c
index f3e07334afd..eca182aa338 100644
--- a/crypto/compress.c
+++ b/crypto/compress.c
@@ -41,21 +41,14 @@ int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags)
int crypto_init_compress_ops(struct crypto_tfm *tfm)
{
- int ret = 0;
struct compress_tfm *ops = &tfm->crt_compress;
-
- ret = tfm->__crt_alg->cra_compress.coa_init(tfm);
- if (ret)
- goto out;
ops->cot_compress = crypto_compress;
ops->cot_decompress = crypto_decompress;
-out:
- return ret;
+ return 0;
}
void crypto_exit_compress_ops(struct crypto_tfm *tfm)
{
- tfm->__crt_alg->cra_compress.coa_exit(tfm);
}
diff --git a/crypto/deflate.c b/crypto/deflate.c
index 5dd2404ae5b..6588bbf82e9 100644
--- a/crypto/deflate.c
+++ b/crypto/deflate.c
@@ -201,9 +201,9 @@ static struct crypto_alg alg = {
.cra_ctxsize = sizeof(struct deflate_ctx),
.cra_module = THIS_MODULE,
.cra_list = LIST_HEAD_INIT(alg.cra_list),
+ .cra_init = deflate_init,
+ .cra_exit = deflate_exit,
.cra_u = { .compress = {
- .coa_init = deflate_init,
- .coa_exit = deflate_exit,
.coa_compress = deflate_compress,
.coa_decompress = deflate_decompress } }
};