On Tue Sep 15 16:35:34 2026 +0800, Guangshuo Li wrote:
> og01a1b_probe() powers the sensor on explicitly before identifying and
> initializing it. After a successful probe, runtime PM is enabled and
> pm_runtime_idle() is used to allow the runtime suspend callback to
> power the sensor off.
> 
> The probe error path explicitly calls og01a1b_power_off(), but the
> normal remove path only disables runtime PM. pm_runtime_disable() does
> not guarantee that an active device is runtime suspended, so the
> sensor can remain powered when the driver is removed. This also leaves
> the xvclk enable performed by og01a1b_power_on() unbalanced.
> 
> After disabling runtime PM, check whether the device is already
> suspended. If it is still active, power the sensor off explicitly and
> update the runtime PM state accordingly. Avoid powering it off again
> when runtime suspend has already done so.
> 
> This issue was found by manual code inspection.
> 
> Fixes: a95ffde28783 ("media: i2c: og01a1b: Add support of xvclk supply clock 
> in power management")
> Cc: [email protected]
> Signed-off-by: Guangshuo Li <[email protected]>
> Signed-off-by: Sakari Ailus <[email protected]>

Patch committed.

Thanks,
Sakari Ailus

 drivers/media/i2c/og01a1b.c | 5 +++++
 1 file changed, 5 insertions(+)

---

diff --git a/drivers/media/i2c/og01a1b.c b/drivers/media/i2c/og01a1b.c
index 1675f0460969..1cece90c59ee 100644
--- a/drivers/media/i2c/og01a1b.c
+++ b/drivers/media/i2c/og01a1b.c
@@ -956,6 +956,11 @@ static void og01a1b_remove(struct i2c_client *client)
        media_entity_cleanup(&sd->entity);
        v4l2_ctrl_handler_free(sd->ctrl_handler);
        pm_runtime_disable(og01a1b->dev);
+
+       if (!pm_runtime_status_suspended(og01a1b->dev)) {
+               og01a1b_power_off(og01a1b->dev);
+               pm_runtime_set_suspended(og01a1b->dev);
+       }
 }
 
 static int og01a1b_probe(struct i2c_client *client)
_______________________________________________
linuxtv-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to