[PATCH 2/2] media: i2c: ov7740: Fix unchecked pm_runtime_get_sync() in remove()

From: Biren Pandya

Date: Mon Jun 15 2026 - 17:06:23 EST


The ov7740_remove() function unconditionally called pm_runtime_get_sync()
but completely ignored the return value. If the device was already in an
error state or disconnected, this could lead to an unbalanced PM runtime
usage count or attempt to communicate with an unresponsive device.

Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() to ensure
the device actually resumed before attempting to issue I2C power-off
commands, and safely put the PM runtime usage counter.

Signed-off-by: Biren Pandya <birenpandya@xxxxxxxxx>
---
drivers/media/i2c/ov7740.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/ov7740.c b/drivers/media/i2c/ov7740.c
index 62c124a1353a..6b81882da307 100644
--- a/drivers/media/i2c/ov7740.c
+++ b/drivers/media/i2c/ov7740.c
@@ -1115,17 +1115,20 @@ static void ov7740_remove(struct i2c_client *client)
{
struct v4l2_subdev *sd = i2c_get_clientdata(client);
struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
+ int ret;

v4l2_async_unregister_subdev(sd);
media_entity_cleanup(&ov7740->subdev.entity);
ov7740_free_controls(ov7740);

- pm_runtime_get_sync(&client->dev);
+ ret = pm_runtime_resume_and_get(&client->dev);
pm_runtime_disable(&client->dev);
pm_runtime_set_suspended(&client->dev);
- pm_runtime_put_noidle(&client->dev);

- ov7740_set_power(ov7740, 0);
+ if (ret >= 0) {
+ ov7740_set_power(ov7740, 0);
+ pm_runtime_put_noidle(&client->dev);
+ }
}

static int __maybe_unused ov7740_runtime_suspend(struct device *dev)
--
2.50.1 (Apple Git-155)