linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] crypto: scompress: return proper error code for allocation failure
@ 2019-03-29 13:09 Sebastian Andrzej Siewior
  2019-03-29 13:09 ` [PATCH 2/2] crypto: scompress: Use per-CPU struct instead multiple variables Sebastian Andrzej Siewior
  2019-04-08  6:40 ` [PATCH 1/2] crypto: scompress: return proper error code for allocation failure Herbert Xu
  0 siblings, 2 replies; 11+ messages in thread
From: Sebastian Andrzej Siewior @ 2019-03-29 13:09 UTC (permalink / raw)
  To: linux-crypto; +Cc: Herbert Xu, tglx, Sebastian Andrzej Siewior

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>
---
 crypto/scompress.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/crypto/scompress.c b/crypto/scompress.c
index 6f8305f8c3004..aea1a8e5d1954 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)
 	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);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-04-12 14:29 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-29 13:09 [PATCH 1/2] crypto: scompress: return proper error code for allocation failure Sebastian Andrzej Siewior
2019-03-29 13:09 ` [PATCH 2/2] crypto: scompress: Use per-CPU struct instead multiple variables Sebastian Andrzej Siewior
2019-04-11  4:07   ` Guenter Roeck
2019-04-11  4:39     ` Eric Biggers
2019-04-12  8:54       ` Sebastian Andrzej Siewior
2019-04-12 13:45         ` Guenter Roeck
2019-04-12  8:42     ` Sebastian Andrzej Siewior
2019-04-12 13:43       ` Guenter Roeck
2019-04-12 13:50         ` Sebastian Andrzej Siewior
2019-04-12 14:29           ` Sebastian Andrzej Siewior
2019-04-08  6:40 ` [PATCH 1/2] crypto: scompress: return proper error code for allocation failure Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).