erofs-utils: decompress: fix QPL job leak on error paths
PATCH v3 1/1 erofs-utils: decompress: fix QPL job leak on error paths
Two early returns in z_erofs_decompress_qpl() after a successful z_erofs_qpl_get_job() skip the cleanup, leaking the job handle. Use goto out_inflate_end instead.
Signed-off-by Shubham Sharma <[email protected]>
--- lib/decompress.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
lib/decompress.c +8 -4
@@ -196,13 +196,17 @@ static int z_erofs_decompress_qpl(struct z_erofs_decompress_req *rq)return PTR_ERR (job); inputmargin =z_erofs_fixup_insize (src, rq->inputsize); -if (inputmargin >= rq->inputsize) -return -EFSCORRUPTED ; +if (inputmargin >= rq->inputsize) { + ret = -EFSCORRUPTED ; + goto out_inflate_end; + }if (rq->decodedskip) { buff =malloc (rq->decodedlength); -if (!buff) -return -ENOMEM ; +if (!buff) { + ret = -ENOMEM ; + goto out_inflate_end; + } dest = buff; }
Signature · 1 line
2.39.1.windows.1
Quoted 5 lines · Vi-shub
Two early returns in
z_erofs_decompress_qpl()after a successfulz_erofs_qpl_get_job()skip the cleanup, leaking the job handle. Use gotoout_inflate_endinstead.Signed-off-by Shubham Sharma <[email protected]>
LGTM, will apply.
Thanks,
Gao Xiang
Hi Gao,
Got it. Thanks for applying.
Shubham Vishwakarma
Quoted 14 lines · Gao Xiang
Quoted 5 lines · Vi-shub
Two early returns in
z_erofs_decompress_qpl()after a successfulz_erofs_qpl_get_job()skip the cleanup, leaking the job handle. Use gotoout_inflate_endinstead.Signed-off-by Shubham Sharma <[email protected]>LGTM, will apply.
Thanks,
Gao Xiang