From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: stanimir.varbanov@linaro.org, agross@kernel.org,
bjorn.andersson@linaro.org, mchehab@kernel.org,
georgi.djakov@linaro.org
Cc: linux-media@vger.kernel.org, linux-arm-msm@lists.infradead.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Subject: [PATCH] media: venus: core: Fix some resource leaks in the error path of 'venus_probe()'
Date: Wed, 27 Jan 2021 21:17:32 +0100 [thread overview]
Message-ID: <20210127201732.743938-1-christophe.jaillet@wanadoo.fr> (raw)
If an error occurs after a successful 'of_icc_get()' call, it must be
undone by a corresponding 'icc_put()' call.
Add it in the error handling path of the probe function as already done in
the remove function.
Fixes: 32f0a6ddc8c9 ("media: venus: Use on-chip interconnect API")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/media/platform/qcom/venus/core.c | 31 +++++++++++++++++-------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
index 0bde19edac86..8fd5da941067 100644
--- a/drivers/media/platform/qcom/venus/core.c
+++ b/drivers/media/platform/qcom/venus/core.c
@@ -200,27 +200,35 @@ static int venus_probe(struct platform_device *pdev)
return PTR_ERR(core->video_path);
core->cpucfg_path = of_icc_get(dev, "cpu-cfg");
- if (IS_ERR(core->cpucfg_path))
- return PTR_ERR(core->cpucfg_path);
+ if (IS_ERR(core->cpucfg_path)) {
+ ret = PTR_ERR(core->cpucfg_path);
+ goto err_video_path_put;
+ }
core->irq = platform_get_irq(pdev, 0);
- if (core->irq < 0)
- return core->irq;
+ if (core->irq < 0) {
+ ret = core->irq;
+ goto err_cpucfg_path_put;
+ }
core->res = of_device_get_match_data(dev);
- if (!core->res)
- return -ENODEV;
+ if (!core->res) {
+ ret = -ENODEV;
+ goto err_cpucfg_path_put;
+ }
mutex_init(&core->pm_lock);
core->pm_ops = venus_pm_get(core->res->hfi_version);
- if (!core->pm_ops)
- return -ENODEV;
+ if (!core->pm_ops) {
+ ret = -ENODEV;
+ goto err_cpucfg_path_put;
+ }
if (core->pm_ops->core_get) {
ret = core->pm_ops->core_get(dev);
if (ret)
- return ret;
+ goto err_cpucfg_path_put;
}
ret = dma_set_mask_and_coherent(dev, core->res->dma_mask);
@@ -305,6 +313,11 @@ static int venus_probe(struct platform_device *pdev)
err_core_put:
if (core->pm_ops->core_put)
core->pm_ops->core_put(dev);
+err_cpucfg_path_put:
+ icc_put(core->cpucfg_path);
+err_video_path_put:
+ icc_put(core->video_path);
+
return ret;
}
--
2.27.0
next reply other threads:[~2021-01-27 20:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-27 20:17 Christophe JAILLET [this message]
2021-01-28 10:49 ` [PATCH] media: venus: core: Fix some resource leaks in the error path of 'venus_probe()' Georgi Djakov
2021-01-28 17:42 ` Christophe JAILLET
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=20210127201732.743938-1-christophe.jaillet@wanadoo.fr \
--to=christophe.jaillet@wanadoo.fr \
--cc=agross@kernel.org \
--cc=bjorn.andersson@linaro.org \
--cc=georgi.djakov@linaro.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-arm-msm@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).