From: Robert Ijtsma Date: Sun, 22 Nov 2026 14:35:51 +0100 Subject: [PATCH 3/5] media: qcom: camss: csid: release parent device on power-on failure MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261122-camss-fixes-v1-3-9df4deb87ea2@gmail.com> References: <20261122-camss-fixes-v1-0-9df4deb87ea2@gmail.com> In-Reply-To: <20261122-camss-fixes-v1-0-9df4deb87ea2@gmail.com> To: Bryan O'Donoghue , Vladimir Zapolskiy , Loic Poulain , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, Robert Ijtsma X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795354550; l=3057; i=robertijtsma@gmail.com; s=20261122; h=from:subject:message-id; bh=HTbUwrQN+kHScODumqx10WGhrvypX+o1LId4XIfvzAA=; b=nmf6BqeXRMJcez+klGQ16Gfctu/v6aLrm/tFPPjbr5x06Gde9TDEuNLOx2+HcJ4QKkKb0uhu1 oECnPw4x4PdBvV4zKtKkZ3ErfYjBkum4Qd7uIvc6gBGuQJIIAHJHO7z X-Developer-Key: i=robertijtsma@gmail.com; a=ed25519; pk=qiDyKVqFicxFIR5sB5m+p9SWPKL2/+mMoiQnUx0C9P0= X-Endpoint-Received: by B4 Relay for robertijtsma@gmail.com/20261122 with auth_id=1604 List-Id: B4 Relay Submissions 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 --- 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