Re: [PATCH v2] media: i2c: ov5647: fix power cleanup on remove
From: Dave Stevenson
Date: Tue Sep 22 2026 - 11:56:21 EST
Thanks Guangshuo
On Tue, 22 Sept 2026 at 09:40, Guangshuo Li <lgs201920130244@xxxxxxxxx> 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@xxxxxxxxxxxxxxx
> Signed-off-by: Guangshuo Li <lgs201920130244@xxxxxxxxx>
Reviewed-by: Dave Stevenson <dave.stevenson@xxxxxxxxxxxxxxx>
> ---
> 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
>