Skip to content

Commit 6a4d1b1

Browse files
Sebastian Andrzej Siewiorherbertx
authored andcommitted
crypto: scompress - return proper error code for allocation failure
If scomp_acomp_comp_decomp() fails to allocate memory for the destination then we never copy back the data we compressed. It is probably best to return an error code instead 0 in case of failure. I haven't found any user that is using acomp_request_set_params() without the `dst' buffer so there is probably no harm. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent d6112ea commit 6a4d1b1

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎crypto/scompress.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,10 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir)
171171
if (!ret) {
172172
if (!req->dst) {
173173
req->dst = sgl_alloc(req->dlen, GFP_ATOMIC, NULL);
174-
if (!req->dst)
174+
if (!req->dst) {
175+
ret = -ENOMEM;
175176
goto out;
177+
}
176178
}
177179
scatterwalk_map_and_copy(scratch_dst, req->dst, 0, req->dlen,
178180
1);

0 commit comments

Comments
 (0)