crypto: serpent - export common functions for x86_64/i386-sse2 assembler implementations
[linux-flexiantxendom0-3.2.10.git] / crypto / zlib.c
index 739b8fc..06b62e5 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/interrupt.h>
 #include <linux/mm.h>
 #include <linux/net.h>
-#include <linux/slab.h>
 
 #include <crypto/internal/compress.h>
 
@@ -60,7 +59,7 @@ static void zlib_decomp_exit(struct zlib_ctx *ctx)
 
        if (stream->workspace) {
                zlib_inflateEnd(stream);
-               kfree(stream->workspace);
+               vfree(stream->workspace);
                stream->workspace = NULL;
        }
 }
@@ -85,6 +84,7 @@ static int zlib_compress_setup(struct crypto_pcomp *tfm, void *params,
        struct zlib_ctx *ctx = crypto_tfm_ctx(crypto_pcomp_tfm(tfm));
        struct z_stream_s *stream = &ctx->comp_stream;
        struct nlattr *tb[ZLIB_COMP_MAX + 1];
+       int window_bits, mem_level;
        size_t workspacesize;
        int ret;
 
@@ -94,7 +94,14 @@ static int zlib_compress_setup(struct crypto_pcomp *tfm, void *params,
 
        zlib_comp_exit(ctx);
 
-       workspacesize = zlib_deflate_workspacesize();
+       window_bits = tb[ZLIB_COMP_WINDOWBITS]
+                                       ? nla_get_u32(tb[ZLIB_COMP_WINDOWBITS])
+                                       : MAX_WBITS;
+       mem_level = tb[ZLIB_COMP_MEMLEVEL]
+                                       ? nla_get_u32(tb[ZLIB_COMP_MEMLEVEL])
+                                       : DEF_MEM_LEVEL;
+
+       workspacesize = zlib_deflate_workspacesize(window_bits, mem_level);
        stream->workspace = vzalloc(workspacesize);
        if (!stream->workspace)
                return -ENOMEM;
@@ -106,12 +113,8 @@ static int zlib_compress_setup(struct crypto_pcomp *tfm, void *params,
                                tb[ZLIB_COMP_METHOD]
                                        ? nla_get_u32(tb[ZLIB_COMP_METHOD])
                                        : Z_DEFLATED,
-                               tb[ZLIB_COMP_WINDOWBITS]
-                                       ? nla_get_u32(tb[ZLIB_COMP_WINDOWBITS])
-                                       : MAX_WBITS,
-                               tb[ZLIB_COMP_MEMLEVEL]
-                                       ? nla_get_u32(tb[ZLIB_COMP_MEMLEVEL])
-                                       : DEF_MEM_LEVEL,
+                               window_bits,
+                               mem_level,
                                tb[ZLIB_COMP_STRATEGY]
                                        ? nla_get_u32(tb[ZLIB_COMP_STRATEGY])
                                        : Z_DEFAULT_STRATEGY);
@@ -224,13 +227,13 @@ static int zlib_decompress_setup(struct crypto_pcomp *tfm, void *params,
                                 ? nla_get_u32(tb[ZLIB_DECOMP_WINDOWBITS])
                                 : DEF_WBITS;
 
-       stream->workspace = kzalloc(zlib_inflate_workspacesize(), GFP_KERNEL);
+       stream->workspace = vzalloc(zlib_inflate_workspacesize());
        if (!stream->workspace)
                return -ENOMEM;
 
        ret = zlib_inflateInit2(stream, ctx->decomp_windowBits);
        if (ret != Z_OK) {
-               kfree(stream->workspace);
+               vfree(stream->workspace);
                stream->workspace = NULL;
                return -EINVAL;
        }