From: Sebastian Andrzej Siewior Date: Fri, 29 Mar 2019 13:09:55 +0000 (+0100) Subject: crypto: scompress - return proper error code for allocation failure X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=6a4d1b18ef00a7b182740b7b4d8a0fcd317368f8;p=openwrt%2Fstaging%2Fblogic.git 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 Signed-off-by: Herbert Xu --- 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) 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);