From: Cong Nguyen <congnt264@gmail.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Tianshu Qiu <tian.shu.qiu@intel.com>,
Bingbu Cao <bingbu.cao@intel.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Shawn Tu <shawnx.tu@intel.com>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] media: i2c: ov2740: fix power leak on remove while runtime-active
Date: Mon, 28 Sep 2026 21:04:48 +0700 [thread overview]
Message-ID: <20260928140448.2404694-1-congnt264@gmail.com> (raw)
ov2740_remove() calls pm_runtime_disable() and nothing else -- it
never calls ov2740_suspend(), which actually powers the sensor down
(asserts reset/powerdown gpios, disables the clock, disables the bulk
regulators). pm_runtime_disable() only blocks future auto suspend/
resume, it doesn't force a final one.
If unbound while the device is genuinely runtime-active (streaming,
or an open subdev fd holding a PM reference), the regulators, clock
and gpios stay in their active state with no code path left to ever
release them.
Call ov2740_suspend() in that case, guarded by
pm_runtime_status_suspended() so the common already-suspended case
isn't suspended twice -- same guard sibling imx412.c's remove() uses.
Moved remove() after suspend()/resume()'s definitions since it now
calls them directly.
Fixes: 866edc895171 ("media: i2c: Add ov2740 image sensor driver")
Assisted-by: LLM
Signed-off-by: Cong Nguyen <congnt264@gmail.com>
---
drivers/media/i2c/ov2740.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c
index fb590dfadda1..fc3710cf3c0e 100644
--- a/drivers/media/i2c/ov2740.c
+++ b/drivers/media/i2c/ov2740.c
@@ -1198,17 +1198,6 @@ static int ov2740_check_hwcfg(struct ov2740 *ov2740)
return ret;
}
-static void ov2740_remove(struct i2c_client *client)
-{
- struct v4l2_subdev *sd = i2c_get_clientdata(client);
-
- v4l2_async_unregister_subdev(sd);
- media_entity_cleanup(&sd->entity);
- v4l2_subdev_cleanup(sd);
- v4l2_ctrl_handler_free(sd->ctrl_handler);
- pm_runtime_disable(&client->dev);
-}
-
static int ov2740_nvmem_read(void *priv, unsigned int off, void *val,
size_t count)
{
@@ -1323,6 +1312,19 @@ static int ov2740_resume(struct device *dev)
return 0;
}
+static void ov2740_remove(struct i2c_client *client)
+{
+ struct v4l2_subdev *sd = i2c_get_clientdata(client);
+
+ v4l2_async_unregister_subdev(sd);
+ media_entity_cleanup(&sd->entity);
+ v4l2_subdev_cleanup(sd);
+ v4l2_ctrl_handler_free(sd->ctrl_handler);
+ pm_runtime_disable(&client->dev);
+ if (!pm_runtime_status_suspended(&client->dev))
+ ov2740_suspend(&client->dev);
+}
+
static int ov2740_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
--
2.25.1
reply other threads:[~2026-09-28 14:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260928140448.2404694-1-congnt264@gmail.com \
--to=congnt264@gmail.com \
--cc=bingbu.cao@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=shawnx.tu@intel.com \
--cc=tian.shu.qiu@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.