diff options
-rw-r--r-- | crypto/api.c | 11 | ||||
-rw-r--r-- | crypto/compress.c | 9 | ||||
-rw-r--r-- | crypto/deflate.c | 4 | ||||
-rw-r--r-- | include/linux/crypto.h | 5 |
4 files changed, 14 insertions, 15 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 | ||
199 | cra_init_failed: | ||
200 | crypto_exit_ops(tfm); | ||
198 | out_free_tfm: | 201 | out_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); |
diff --git a/crypto/compress.c b/crypto/compress.c index f3e07334afd0..eca182aa3380 100644 --- a/crypto/compress.c +++ b/crypto/compress.c | |||
@@ -41,21 +41,14 @@ int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags) | |||
41 | 41 | ||
42 | int crypto_init_compress_ops(struct crypto_tfm *tfm) | 42 | int crypto_init_compress_ops(struct crypto_tfm *tfm) |
43 | { | 43 | { |
44 | int ret = 0; | ||
45 | struct compress_tfm *ops = &tfm->crt_compress; | 44 | struct compress_tfm *ops = &tfm->crt_compress; |
46 | |||
47 | ret = tfm->__crt_alg->cra_compress.coa_init(tfm); | ||
48 | if (ret) | ||
49 | goto out; | ||
50 | 45 | ||
51 | ops->cot_compress = crypto_compress; | 46 | ops->cot_compress = crypto_compress; |
52 | ops->cot_decompress = crypto_decompress; | 47 | ops->cot_decompress = crypto_decompress; |
53 | 48 | ||
54 | out: | 49 | return 0; |
55 | return ret; | ||
56 | } | 50 | } |
57 | 51 | ||
58 | void crypto_exit_compress_ops(struct crypto_tfm *tfm) | 52 | void crypto_exit_compress_ops(struct crypto_tfm *tfm) |
59 | { | 53 | { |
60 | tfm->__crt_alg->cra_compress.coa_exit(tfm); | ||
61 | } | 54 | } |
diff --git a/crypto/deflate.c b/crypto/deflate.c index 5dd2404ae5b2..6588bbf82e9b 100644 --- a/crypto/deflate.c +++ b/crypto/deflate.c | |||
@@ -201,9 +201,9 @@ static struct crypto_alg alg = { | |||
201 | .cra_ctxsize = sizeof(struct deflate_ctx), | 201 | .cra_ctxsize = sizeof(struct deflate_ctx), |
202 | .cra_module = THIS_MODULE, | 202 | .cra_module = THIS_MODULE, |
203 | .cra_list = LIST_HEAD_INIT(alg.cra_list), | 203 | .cra_list = LIST_HEAD_INIT(alg.cra_list), |
204 | .cra_init = deflate_init, | ||
205 | .cra_exit = deflate_exit, | ||
204 | .cra_u = { .compress = { | 206 | .cra_u = { .compress = { |
205 | .coa_init = deflate_init, | ||
206 | .coa_exit = deflate_exit, | ||
207 | .coa_compress = deflate_compress, | 207 | .coa_compress = deflate_compress, |
208 | .coa_decompress = deflate_decompress } } | 208 | .coa_decompress = deflate_decompress } } |
209 | }; | 209 | }; |
diff --git a/include/linux/crypto.h b/include/linux/crypto.h index ef918803ec30..6c013c88080f 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h | |||
@@ -109,8 +109,6 @@ struct digest_alg { | |||
109 | }; | 109 | }; |
110 | 110 | ||
111 | struct compress_alg { | 111 | struct compress_alg { |
112 | int (*coa_init)(struct crypto_tfm *tfm); | ||
113 | void (*coa_exit)(struct crypto_tfm *tfm); | ||
114 | int (*coa_compress)(struct crypto_tfm *tfm, const u8 *src, | 112 | int (*coa_compress)(struct crypto_tfm *tfm, const u8 *src, |
115 | unsigned int slen, u8 *dst, unsigned int *dlen); | 113 | unsigned int slen, u8 *dst, unsigned int *dlen); |
116 | int (*coa_decompress)(struct crypto_tfm *tfm, const u8 *src, | 114 | int (*coa_decompress)(struct crypto_tfm *tfm, const u8 *src, |
@@ -138,6 +136,9 @@ struct crypto_alg { | |||
138 | struct digest_alg digest; | 136 | struct digest_alg digest; |
139 | struct compress_alg compress; | 137 | struct compress_alg compress; |
140 | } cra_u; | 138 | } cra_u; |
139 | |||
140 | int (*cra_init)(struct crypto_tfm *tfm); | ||
141 | void (*cra_exit)(struct crypto_tfm *tfm); | ||
141 | 142 | ||
142 | struct module *cra_module; | 143 | struct module *cra_module; |
143 | }; | 144 | }; |