3 @@ -914,24 +914,25 @@ static int test_pcomp(struct crypto_pcom
4 const char *algo = crypto_tfm_alg_driver_name(crypto_pcomp_tfm(tfm));
6 char result[COMP_BUF_SIZE];
10 for (i = 0; i < ctcount; i++) {
11 struct comp_request req;
12 + unsigned int produced = 0;
14 - error = crypto_compress_setup(tfm, ctemplate[i].params,
15 - ctemplate[i].paramsize);
17 + res = crypto_compress_setup(tfm, ctemplate[i].params,
18 + ctemplate[i].paramsize);
20 pr_err("alg: pcomp: compression setup failed on test "
21 - "%d for %s: error=%d\n", i + 1, algo, error);
23 + "%d for %s: error=%d\n", i + 1, algo, res);
27 - error = crypto_compress_init(tfm);
29 + res = crypto_compress_init(tfm);
31 pr_err("alg: pcomp: compression init failed on test "
32 - "%d for %s: error=%d\n", i + 1, algo, error);
34 + "%d for %s: error=%d\n", i + 1, algo, res);
38 memset(result, 0, sizeof(result));
39 @@ -941,32 +942,37 @@ static int test_pcomp(struct crypto_pcom
40 req.next_out = result;
41 req.avail_out = ctemplate[i].outlen / 2;
43 - error = crypto_compress_update(tfm, &req);
44 - if (error && (error != -EAGAIN || req.avail_in)) {
45 + res = crypto_compress_update(tfm, &req);
46 + if (res < 0 && (res != -EAGAIN || req.avail_in)) {
47 pr_err("alg: pcomp: compression update failed on test "
48 - "%d for %s: error=%d\n", i + 1, algo, error);
50 + "%d for %s: error=%d\n", i + 1, algo, res);
56 /* Add remaining input data */
57 req.avail_in += (ctemplate[i].inlen + 1) / 2;
59 - error = crypto_compress_update(tfm, &req);
60 - if (error && (error != -EAGAIN || req.avail_in)) {
61 + res = crypto_compress_update(tfm, &req);
62 + if (res < 0 && (res != -EAGAIN || req.avail_in)) {
63 pr_err("alg: pcomp: compression update failed on test "
64 - "%d for %s: error=%d\n", i + 1, algo, error);
66 + "%d for %s: error=%d\n", i + 1, algo, res);
72 /* Provide remaining output space */
73 req.avail_out += COMP_BUF_SIZE - ctemplate[i].outlen / 2;
75 - error = crypto_compress_final(tfm, &req);
77 + res = crypto_compress_final(tfm, &req);
79 pr_err("alg: pcomp: compression final failed on test "
80 - "%d for %s: error=%d\n", i + 1, algo, error);
82 + "%d for %s: error=%d\n", i + 1, algo, res);
87 if (COMP_BUF_SIZE - req.avail_out != ctemplate[i].outlen) {
88 pr_err("alg: comp: Compression test %d failed for %s: "
89 @@ -976,6 +982,13 @@ static int test_pcomp(struct crypto_pcom
93 + if (produced != ctemplate[i].outlen) {
94 + pr_err("alg: comp: Compression test %d failed for %s: "
95 + "returned len = %u (expected %d)\n", i + 1,
96 + algo, produced, ctemplate[i].outlen);
100 if (memcmp(result, ctemplate[i].output, ctemplate[i].outlen)) {
101 pr_err("alg: pcomp: Compression test %d failed for "
102 "%s\n", i + 1, algo);
103 @@ -986,21 +999,21 @@ static int test_pcomp(struct crypto_pcom
105 for (i = 0; i < dtcount; i++) {
106 struct comp_request req;
107 + unsigned int produced = 0;
109 - error = crypto_decompress_setup(tfm, dtemplate[i].params,
110 - dtemplate[i].paramsize);
112 + res = crypto_decompress_setup(tfm, dtemplate[i].params,
113 + dtemplate[i].paramsize);
115 pr_err("alg: pcomp: decompression setup failed on "
116 - "test %d for %s: error=%d\n", i + 1, algo,
119 + "test %d for %s: error=%d\n", i + 1, algo, res);
123 - error = crypto_decompress_init(tfm);
125 + res = crypto_decompress_init(tfm);
127 pr_err("alg: pcomp: decompression init failed on test "
128 - "%d for %s: error=%d\n", i + 1, algo, error);
130 + "%d for %s: error=%d\n", i + 1, algo, res);
134 memset(result, 0, sizeof(result));
135 @@ -1010,35 +1023,38 @@ static int test_pcomp(struct crypto_pcom
136 req.next_out = result;
137 req.avail_out = dtemplate[i].outlen / 2;
139 - error = crypto_decompress_update(tfm, &req);
140 - if (error && (error != -EAGAIN || req.avail_in)) {
141 + res = crypto_decompress_update(tfm, &req);
142 + if (res < 0 && (res != -EAGAIN || req.avail_in)) {
143 pr_err("alg: pcomp: decompression update failed on "
144 - "test %d for %s: error=%d\n", i + 1, algo,
147 + "test %d for %s: error=%d\n", i + 1, algo, res);
153 /* Add remaining input data */
154 req.avail_in += (dtemplate[i].inlen + 1) / 2;
156 - error = crypto_decompress_update(tfm, &req);
157 - if (error && (error != -EAGAIN || req.avail_in)) {
158 + res = crypto_decompress_update(tfm, &req);
159 + if (res < 0 && (res != -EAGAIN || req.avail_in)) {
160 pr_err("alg: pcomp: decompression update failed on "
161 - "test %d for %s: error=%d\n", i + 1, algo,
164 + "test %d for %s: error=%d\n", i + 1, algo, res);
170 /* Provide remaining output space */
171 req.avail_out += COMP_BUF_SIZE - dtemplate[i].outlen / 2;
173 - error = crypto_decompress_final(tfm, &req);
174 - if (error && (error != -EAGAIN || req.avail_in)) {
175 + res = crypto_decompress_final(tfm, &req);
176 + if (res < 0 && (res != -EAGAIN || req.avail_in)) {
177 pr_err("alg: pcomp: decompression final failed on "
178 - "test %d for %s: error=%d\n", i + 1, algo,
181 + "test %d for %s: error=%d\n", i + 1, algo, res);
187 if (COMP_BUF_SIZE - req.avail_out != dtemplate[i].outlen) {
188 pr_err("alg: comp: Decompression test %d failed for "
189 @@ -1048,6 +1064,13 @@ static int test_pcomp(struct crypto_pcom
193 + if (produced != dtemplate[i].outlen) {
194 + pr_err("alg: comp: Decompression test %d failed for "
195 + "%s: returned len = %u (expected %d)\n", i + 1,
196 + algo, produced, dtemplate[i].outlen);
200 if (memcmp(result, dtemplate[i].output, dtemplate[i].outlen)) {
201 pr_err("alg: pcomp: Decompression test %d failed for "
202 "%s\n", i + 1, algo);
205 @@ -165,15 +165,15 @@ static int zlib_compress_update(struct c
209 + ret = req->avail_out - stream->avail_out;
210 pr_debug("avail_in %u, avail_out %u (consumed %u, produced %u)\n",
211 stream->avail_in, stream->avail_out,
212 - req->avail_in - stream->avail_in,
213 - req->avail_out - stream->avail_out);
214 + req->avail_in - stream->avail_in, ret);
215 req->next_in = stream->next_in;
216 req->avail_in = stream->avail_in;
217 req->next_out = stream->next_out;
218 req->avail_out = stream->avail_out;
223 static int zlib_compress_final(struct crypto_pcomp *tfm,
224 @@ -195,15 +195,15 @@ static int zlib_compress_final(struct cr
228 + ret = req->avail_out - stream->avail_out;
229 pr_debug("avail_in %u, avail_out %u (consumed %u, produced %u)\n",
230 stream->avail_in, stream->avail_out,
231 - req->avail_in - stream->avail_in,
232 - req->avail_out - stream->avail_out);
233 + req->avail_in - stream->avail_in, ret);
234 req->next_in = stream->next_in;
235 req->avail_in = stream->avail_in;
236 req->next_out = stream->next_out;
237 req->avail_out = stream->avail_out;
243 @@ -280,15 +280,15 @@ static int zlib_decompress_update(struct
247 + ret = req->avail_out - stream->avail_out;
248 pr_debug("avail_in %u, avail_out %u (consumed %u, produced %u)\n",
249 stream->avail_in, stream->avail_out,
250 - req->avail_in - stream->avail_in,
251 - req->avail_out - stream->avail_out);
252 + req->avail_in - stream->avail_in, ret);
253 req->next_in = stream->next_in;
254 req->avail_in = stream->avail_in;
255 req->next_out = stream->next_out;
256 req->avail_out = stream->avail_out;
261 static int zlib_decompress_final(struct crypto_pcomp *tfm,
262 @@ -328,15 +328,15 @@ static int zlib_decompress_final(struct
266 + ret = req->avail_out - stream->avail_out;
267 pr_debug("avail_in %u, avail_out %u (consumed %u, produced %u)\n",
268 stream->avail_in, stream->avail_out,
269 - req->avail_in - stream->avail_in,
270 - req->avail_out - stream->avail_out);
271 + req->avail_in - stream->avail_in, ret);
272 req->next_in = stream->next_in;
273 req->avail_in = stream->avail_in;
274 req->next_out = stream->next_out;
275 req->avail_out = stream->avail_out;