From: Ameer Hamza <amhamza.mgc@gmail.com>
To: kieran.bingham@ideasonboard.com
Cc: agross@kernel.org, bjorn.andersson@linaro.org,
mchehab@kernel.org, stanimir.varbanov@linaro.org,
linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, amhamza.mgc@gmail.com
Subject: [PATCH v3] media: venus: vdec: fixed possible memory leak issue
Date: Mon, 6 Dec 2021 15:43:15 +0500 [thread overview]
Message-ID: <20211206104315.12516-1-amhamza.mgc@gmail.com> (raw)
In-Reply-To: <163878547435.2211244.3536763956780138208@Monstersaurus>
The venus_helper_alloc_dpb_bufs() implementation allows an early return
on an error path when checking the id from ida_alloc_min() which would
not release the earlier buffer allocation.
Move the direct kfree() from the error checking of dma_alloc_attrs() to
the common fail path to ensure that allocations are released on all
error paths in this function.
Addresses-Coverity: 1494120 ("Resource leak")
Fixes: 40d87aafee29 ("media: venus: vdec: decoded picture buffer handling during reconfig sequence")
Signed-off-by: Ameer Hamza <amhamza.mgc@gmail.com>
---
Changes in v3:
Updated description and added fix tag
---
drivers/media/platform/qcom/venus/helpers.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
index 84c3a511ec31..0bca95d01650 100644
--- a/drivers/media/platform/qcom/venus/helpers.c
+++ b/drivers/media/platform/qcom/venus/helpers.c
@@ -189,7 +189,6 @@ int venus_helper_alloc_dpb_bufs(struct venus_inst *inst)
buf->va = dma_alloc_attrs(dev, buf->size, &buf->da, GFP_KERNEL,
buf->attrs);
if (!buf->va) {
- kfree(buf);
ret = -ENOMEM;
goto fail;
}
@@ -209,6 +208,7 @@ int venus_helper_alloc_dpb_bufs(struct venus_inst *inst)
return 0;
fail:
+ kfree(buf);
venus_helper_free_dpb_bufs(inst);
return ret;
}
--
2.25.1
next prev parent reply other threads:[~2021-12-06 10:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-04 12:11 [PATCH] media: venus: vdec: fixed possible memory leak issue Ameer Hamza
2021-12-04 20:29 ` Kieran Bingham
2021-12-04 20:55 ` [PATCH v2] " Ameer Hamza
2021-12-06 9:55 ` Kieran Bingham
2021-12-06 10:11 ` Kieran Bingham
2021-12-06 10:43 ` Ameer Hamza [this message]
2021-12-06 11:32 ` [PATCH v3] " Kieran Bingham
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211206104315.12516-1-amhamza.mgc@gmail.com \
--to=amhamza.mgc@gmail.com \
--cc=agross@kernel.org \
--cc=bjorn.andersson@linaro.org \
--cc=kieran.bingham@ideasonboard.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=stanimir.varbanov@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox