media: i2c: ov5647: fix power cleanup on remove
Subsystems (4)
PATCH v2 1/1 media: i2c: ov5647: fix power cleanup on remove
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.
---
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(+)
drivers/media/i2c/ov5647.c +4 -0
@@ -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 = {
Signature · 1 line
2.43.0
Thanks Guangshuo
Quoted 5 lines · Guangshuo Li
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.
Quoted 8 lines
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")Signed-off-by Guangshuo Li <[email protected]>
Quoted 26 lines
---
v2 :
- Movepm_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(+)drivers/media/i2c/ov5647.c +4
-1@@ -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