-static int deflate_compress(void *ctx, const u8 *src, unsigned int slen,
- u8 *dst, unsigned int *dlen)
+static void deflate_comp_exit(struct deflate_ctx *ctx)
+{
+ zlib_deflateEnd(&ctx->comp_stream);
+ vfree(ctx->comp_stream.workspace);
+}
+
+static void deflate_decomp_exit(struct deflate_ctx *ctx)
+{
+ zlib_inflateEnd(&ctx->decomp_stream);
+ kfree(ctx->decomp_stream.workspace);
+}
+
+static int deflate_init(struct crypto_tfm *tfm)
+{
+ struct deflate_ctx *ctx = crypto_tfm_ctx(tfm);
+ int ret;
+
+ ret = deflate_comp_init(ctx);
+ if (ret)
+ goto out;
+ ret = deflate_decomp_init(ctx);
+ if (ret)
+ deflate_comp_exit(ctx);
+out:
+ return ret;
+}
+
+static void deflate_exit(struct crypto_tfm *tfm)
+{
+ struct deflate_ctx *ctx = crypto_tfm_ctx(tfm);
+
+ deflate_comp_exit(ctx);
+ deflate_decomp_exit(ctx);
+}
+
+static int deflate_compress(struct crypto_tfm *tfm, const u8 *src,
+ unsigned int slen, u8 *dst, unsigned int *dlen)