From: Robert Ijtsma via B4 Relay <devnull+robertijtsma.gmail.com@kernel.org>
To: Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>,
Loic Poulain <loic.poulain@oss.qualcomm.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
Robert Ijtsma <robertijtsma@gmail.com>
Subject: [PATCH 3/5] media: qcom: camss: csid: release parent device on power-on failure
Date: Sun, 22 Nov 2026 14:35:51 +0100 [thread overview]
Message-ID: <20261122-camss-fixes-v1-3-9df4deb87ea2@gmail.com> (raw)
In-Reply-To: <20261122-camss-fixes-v1-0-9df4deb87ea2@gmail.com>
From: Robert Ijtsma <robertijtsma@gmail.com>
csid_set_power() acquires a reference on the parent device via
parent_dev_ops->get() before resuming runtime PM, enabling regulators
and clocks, and resetting the CSID hardware. If any of these subsequent
steps fail, the function returns without calling parent_dev_ops->put(),
leaking the parent VFE power reference.
Consolidate the power-on error paths using goto labels and release the
parent device reference on all failure paths.
Fixes: c5af8db84c01 ("media: camss: Do vfe_get/vfe_put for csid on sm8250")
Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
---
drivers/media/platform/qcom/camss/camss-csid.c | 48 ++++++++++++--------------
1 file changed, 22 insertions(+), 26 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c
index 51f2090..e67edc3 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.c
+++ b/drivers/media/platform/qcom/camss/camss-csid.c
@@ -682,7 +682,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
struct csid_device *csid = v4l2_get_subdevdata(sd);
struct camss *camss = csid->camss;
struct device *dev = camss->dev;
- int ret = 0;
+ int ret;
if (on) {
/*
@@ -696,44 +696,28 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
ret = pm_runtime_resume_and_get(dev);
if (ret < 0)
- return ret;
+ goto err_parent_put;
ret = regulator_bulk_enable(csid->num_supplies,
csid->supplies);
- if (ret < 0) {
- pm_runtime_put_sync(dev);
- return ret;
- }
+ if (ret < 0)
+ goto err_pm_put;
ret = csid_set_clock_rates(csid);
- if (ret < 0) {
- regulator_bulk_disable(csid->num_supplies,
- csid->supplies);
- pm_runtime_put_sync(dev);
- return ret;
- }
+ if (ret < 0)
+ goto err_regulators_disable;
ret = camss_enable_clocks(csid->nclocks, csid->clock, dev);
- if (ret < 0) {
- regulator_bulk_disable(csid->num_supplies,
- csid->supplies);
- pm_runtime_put_sync(dev);
- return ret;
- }
+ if (ret < 0)
+ goto err_regulators_disable;
csid->phy.need_vc_update = true;
enable_irq(csid->irq);
ret = csid->res->hw_ops->reset(csid);
- if (ret < 0) {
- disable_irq(csid->irq);
- camss_disable_clocks(csid->nclocks, csid->clock);
- regulator_bulk_disable(csid->num_supplies,
- csid->supplies);
- pm_runtime_put_sync(dev);
- return ret;
- }
+ if (ret < 0)
+ goto err_reset;
csid->res->hw_ops->hw_version(csid);
} else {
@@ -745,6 +729,18 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
csid->res->parent_dev_ops->put(camss, csid->id);
}
+ return 0;
+
+err_reset:
+ disable_irq(csid->irq);
+ camss_disable_clocks(csid->nclocks, csid->clock);
+err_regulators_disable:
+ regulator_bulk_disable(csid->num_supplies, csid->supplies);
+err_pm_put:
+ pm_runtime_put_sync(dev);
+err_parent_put:
+ csid->res->parent_dev_ops->put(camss, csid->id);
+
return ret;
}
--
2.56.0
next prev parent reply other threads:[~2026-11-22 13:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 13:35 [PATCH 0/5] media: qcom: camss: fix VFE/CSID/video error handling and register bugs Robert Ijtsma via B4 Relay
2026-11-22 13:35 ` [PATCH 1/5] media: qcom: camss: vfe-17x: check status1 for RDI SOF interrupts Robert Ijtsma via B4 Relay
2026-11-22 13:35 ` [PATCH 2/5] media: qcom: camss: csid-gen2: fix RDI enable bit manipulation Robert Ijtsma via B4 Relay
2026-11-22 13:35 ` Robert Ijtsma via B4 Relay [this message]
2026-11-22 13:35 ` [PATCH 4/5] media: qcom: camss: vfe: destroy mutexes after unregistering entities Robert Ijtsma via B4 Relay
2026-11-22 13:35 ` [PATCH 5/5] media: qcom: camss: video: stop started subdevs on start_streaming failure Robert Ijtsma via B4 Relay
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=20261122-camss-fixes-v1-3-9df4deb87ea2@gmail.com \
--to=devnull+robertijtsma.gmail.com@kernel.org \
--cc=bryan.odonoghue@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=loic.poulain@oss.qualcomm.com \
--cc=mchehab@kernel.org \
--cc=robertijtsma@gmail.com \
--cc=vladimir.zapolskiy@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