[PATCH v2 10/16] media: i2c: ov5648: power off the sensor on remove

From: Cong Nguyen

Date: Mon Nov 23 2026 - 10:40:26 EST


ov5648_probe() ends with the device runtime suspended, and
ov5648_s_stream() takes a runtime PM reference with
pm_runtime_resume_and_get() when streaming starts and drops it when
streaming stops. ov5648_remove() only calls pm_runtime_disable(), which
does not run the runtime suspend callback, so a device that is still
runtime active when the driver is unbound can keep its regulators and clock
enabled and its GPIOs released.

After disabling runtime PM, call ov5648_sensor_power(sensor, false) if
the device is not runtime suspended, and set the runtime PM status to
suspended. Avoid powering it off again when runtime suspend has already
done so.

This issue was found by auditing the driver with an LLM coding assistant.

Fixes: e43ccb0a045f ("media: i2c: Add support for the OV5648 image sensor")
Signed-off-by: Cong Nguyen <congnt264@xxxxxxxxx>
---
drivers/media/i2c/ov5648.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/media/i2c/ov5648.c b/drivers/media/i2c/ov5648.c
index bb06e66d28e0..7b817511ab93 100644
--- a/drivers/media/i2c/ov5648.c
+++ b/drivers/media/i2c/ov5648.c
@@ -2603,6 +2603,10 @@ static void ov5648_remove(struct i2c_client *client)

v4l2_async_unregister_subdev(subdev);
pm_runtime_disable(sensor->dev);
+ if (!pm_runtime_status_suspended(sensor->dev)) {
+ ov5648_sensor_power(sensor, false);
+ pm_runtime_set_suspended(sensor->dev);
+ }
v4l2_ctrl_handler_free(&sensor->ctrls.handler);
mutex_destroy(&sensor->mutex);
media_entity_cleanup(&subdev->entity);
--
2.25.1