[PATCH v2] media: i2c: ov5647: fix power cleanup on remove

Guangshuo Li posted 1 patch 2 days, 6 hours ago
drivers/media/i2c/ov5647.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH v2] media: i2c: ov5647: fix power cleanup on remove
Posted by Guangshuo Li 2 days, 6 hours ago
ov5647_remove() disables runtime PM without powering off the sensor if
it is still runtime active. pm_runtime_disable() does not invoke the
runtime suspend callback, so the sensor can remain powered on.

If the device is not already runtime suspended, call ov5647_power_off()
and mark the runtime PM state as suspended.

This issue was found by manual code inspection.

Fixes: 089b7c70f0d8 ("media: ov5647: Use pm_runtime infrastructure")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
v2 :
  - Move pm_runtime_set_suspended() into the conditional so it is only
    called when the sensor is explicitly powered off.

 drivers/media/i2c/ov5647.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index 3facf92b3841..3b3e5653a0c6 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -1271,6 +1271,10 @@ static void ov5647_remove(struct i2c_client *client)
 	v4l2_ctrl_handler_free(&sensor->ctrls);
 	v4l2_device_unregister_subdev(sd);
 	pm_runtime_disable(&client->dev);
+	if (!pm_runtime_status_suspended(&client->dev)) {
+		ov5647_power_off(&client->dev);
+		pm_runtime_set_suspended(&client->dev);
+	}
 }
 
 static const struct dev_pm_ops ov5647_pm_ops = {
-- 
2.43.0
Re: [PATCH v2] media: i2c: ov5647: fix power cleanup on remove
Posted by Dave Stevenson 1 day, 23 hours ago
Thanks Guangshuo

On Tue, 22 Sept 2026 at 09:40, Guangshuo Li <lgs201920130244@gmail.com> wrote:
>
> ov5647_remove() disables runtime PM without powering off the sensor if
> it is still runtime active. pm_runtime_disable() does not invoke the
> runtime suspend callback, so the sensor can remain powered on.
>
> If the device is not already runtime suspended, call ov5647_power_off()
> and mark the runtime PM state as suspended.
>
> This issue was found by manual code inspection.
>
> Fixes: 089b7c70f0d8 ("media: ov5647: Use pm_runtime infrastructure")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>

Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

> ---
> v2 :
>   - Move pm_runtime_set_suspended() into the conditional so it is only
>     called when the sensor is explicitly powered off.
>
>  drivers/media/i2c/ov5647.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
> index 3facf92b3841..3b3e5653a0c6 100644
> --- a/drivers/media/i2c/ov5647.c
> +++ b/drivers/media/i2c/ov5647.c
> @@ -1271,6 +1271,10 @@ static void ov5647_remove(struct i2c_client *client)
>         v4l2_ctrl_handler_free(&sensor->ctrls);
>         v4l2_device_unregister_subdev(sd);
>         pm_runtime_disable(&client->dev);
> +       if (!pm_runtime_status_suspended(&client->dev)) {
> +               ov5647_power_off(&client->dev);
> +               pm_runtime_set_suspended(&client->dev);
> +       }
>  }
>
>  static const struct dev_pm_ops ov5647_pm_ops = {
> --
> 2.43.0
>