Skip to content

Commit

Permalink
crypto: scompress - return proper error code for allocation failure
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sebastian Andrzej Siewior authored and Herbert Xu committed Apr 8, 2019
1 parent d6112ea commit 6a4d1b1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crypto/scompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,10 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir)
if (!ret) {
if (!req->dst) {
req->dst = sgl_alloc(req->dlen, GFP_ATOMIC, NULL);
if (!req->dst)
if (!req->dst) {
ret = -ENOMEM;
goto out;
}
}
scatterwalk_map_and_copy(scratch_dst, req->dst, 0, req->dlen,
1);
Expand Down

0 comments on commit 6a4d1b1

Please sign in to comment.