[PATCH v2 08/16] media: i2c: ov5670: do not power off twice on remove
From: Cong Nguyen
Date: Mon Nov 23 2026 - 10:40:16 EST
ov5670_remove() calls ov5670_runtime_suspend() unconditionally after
pm_runtime_disable(). In the usual case the device is already runtime
suspended by then, because probe ends with pm_runtime_idle() and the
stream has stopped, so the regulators and the clock are disabled a
second time. That can trigger the unbalanced disable warnings from the
regulator and clock cores.
Only call ov5670_runtime_suspend() if the device is not runtime
suspended, and set the runtime PM status to suspended afterwards. This
also covers the case where the device is still runtime active, which
the unconditional call handled by accident.
This issue was found by auditing the driver with an LLM coding assistant.
Fixes: 62ab1e325978 ("media: i2c: ov5670: Add runtime_pm operations")
Signed-off-by: Cong Nguyen <congnt264@xxxxxxxxx>
---
drivers/media/i2c/ov5670.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c
index 90352140e5fe..dcf335abcf5b 100644
--- a/drivers/media/i2c/ov5670.c
+++ b/drivers/media/i2c/ov5670.c
@@ -2786,7 +2786,10 @@ static void ov5670_remove(struct i2c_client *client)
mutex_destroy(&ov5670->mutex);
pm_runtime_disable(ov5670->dev);
- ov5670_runtime_suspend(ov5670->dev);
+ if (!pm_runtime_status_suspended(ov5670->dev)) {
+ ov5670_runtime_suspend(ov5670->dev);
+ pm_runtime_set_suspended(ov5670->dev);
+ }
v4l2_fwnode_endpoint_free(&ov5670->endpoint);
}
--
2.25.1