crypto: Use vzalloc
[linux-3.10.git] / crypto / zlib.c
index 33609ba..739b8fc 100644 (file)
@@ -95,11 +95,10 @@ static int zlib_compress_setup(struct crypto_pcomp *tfm, void *params,
        zlib_comp_exit(ctx);
 
        workspacesize = zlib_deflate_workspacesize();
-       stream->workspace = vmalloc(workspacesize);
+       stream->workspace = vzalloc(workspacesize);
        if (!stream->workspace)
                return -ENOMEM;
 
-       memset(stream->workspace, 0, workspacesize);
        ret = zlib_deflateInit2(stream,
                                tb[ZLIB_COMP_LEVEL]
                                        ? nla_get_u32(tb[ZLIB_COMP_LEVEL])
@@ -165,15 +164,15 @@ static int zlib_compress_update(struct crypto_pcomp *tfm,
                return -EINVAL;
        }
 
+       ret = req->avail_out - stream->avail_out;
        pr_debug("avail_in %u, avail_out %u (consumed %u, produced %u)\n",
                 stream->avail_in, stream->avail_out,
-                req->avail_in - stream->avail_in,
-                req->avail_out - stream->avail_out);
+                req->avail_in - stream->avail_in, ret);
        req->next_in = stream->next_in;
        req->avail_in = stream->avail_in;
        req->next_out = stream->next_out;
        req->avail_out = stream->avail_out;
-       return 0;
+       return ret;
 }
 
 static int zlib_compress_final(struct crypto_pcomp *tfm,
@@ -195,15 +194,15 @@ static int zlib_compress_final(struct crypto_pcomp *tfm,
                return -EINVAL;
        }
 
+       ret = req->avail_out - stream->avail_out;
        pr_debug("avail_in %u, avail_out %u (consumed %u, produced %u)\n",
                 stream->avail_in, stream->avail_out,
-                req->avail_in - stream->avail_in,
-                req->avail_out - stream->avail_out);
+                req->avail_in - stream->avail_in, ret);
        req->next_in = stream->next_in;
        req->avail_in = stream->avail_in;
        req->next_out = stream->next_out;
        req->avail_out = stream->avail_out;
-       return 0;
+       return ret;
 }
 
 
@@ -280,15 +279,15 @@ static int zlib_decompress_update(struct crypto_pcomp *tfm,
                return -EINVAL;
        }
 
+       ret = req->avail_out - stream->avail_out;
        pr_debug("avail_in %u, avail_out %u (consumed %u, produced %u)\n",
                 stream->avail_in, stream->avail_out,
-                req->avail_in - stream->avail_in,
-                req->avail_out - stream->avail_out);
+                req->avail_in - stream->avail_in, ret);
        req->next_in = stream->next_in;
        req->avail_in = stream->avail_in;
        req->next_out = stream->next_out;
        req->avail_out = stream->avail_out;
-       return 0;
+       return ret;
 }
 
 static int zlib_decompress_final(struct crypto_pcomp *tfm,
@@ -328,15 +327,15 @@ static int zlib_decompress_final(struct crypto_pcomp *tfm,
                return -EINVAL;
        }
 
+       ret = req->avail_out - stream->avail_out;
        pr_debug("avail_in %u, avail_out %u (consumed %u, produced %u)\n",
                 stream->avail_in, stream->avail_out,
-                req->avail_in - stream->avail_in,
-                req->avail_out - stream->avail_out);
+                req->avail_in - stream->avail_in, ret);
        req->next_in = stream->next_in;
        req->avail_in = stream->avail_in;
        req->next_out = stream->next_out;
        req->avail_out = stream->avail_out;
-       return 0;
+       return ret;
 }