diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2019-03-29 09:09:55 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2019-04-08 02:36:16 -0400 |
commit | 6a4d1b18ef00a7b182740b7b4d8a0fcd317368f8 (patch) | |
tree | 07869c8b028f77343aa984312331f8ae65915b5c /crypto/scompress.c | |
parent | d6112ea0cb344d6f5ed519991e24f69ba4b43d0e (diff) |
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>
Diffstat (limited to 'crypto/scompress.c')
-rw-r--r-- | crypto/scompress.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/scompress.c b/crypto/scompress.c index 6f8305f8c300..aea1a8e5d195 100644 --- a/crypto/scompress.c +++ b/crypto/scompress.c | |||
@@ -171,8 +171,10 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir) | |||
171 | if (!ret) { | 171 | if (!ret) { |
172 | if (!req->dst) { | 172 | if (!req->dst) { |
173 | req->dst = sgl_alloc(req->dlen, GFP_ATOMIC, NULL); | 173 | req->dst = sgl_alloc(req->dlen, GFP_ATOMIC, NULL); |
174 | if (!req->dst) | 174 | if (!req->dst) { |
175 | ret = -ENOMEM; | ||
175 | goto out; | 176 | goto out; |
177 | } | ||
176 | } | 178 | } |
177 | scatterwalk_map_and_copy(scratch_dst, req->dst, 0, req->dlen, | 179 | scatterwalk_map_and_copy(scratch_dst, req->dst, 0, req->dlen, |
178 | 1); | 180 | 1); |