Skip to contentSkip to conversation

media: i2c: ov5647: fix power leak on remove while runtime-active

PATCH New Cong Nguyen 1 participant 1 message Sep 28

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: i2c: ov5647: fix power leak on remove while runtime-active

ov5647_remove() calls pm_runtime_disable() and nothing else -- it never calls ov5647_power_off(), which actually powers the sensor down (disables the imaging clock, asserts the powerdown gpio, disables the bulk regulators). pm_runtime_disable() only blocks future auto suspend/resume, it doesn't force a final one.

If unbound while the device is genuinely runtime-active (streaming, or an open subdev fd holding a PM reference), the clock, gpio and regulators stay in their active state with no code path left to ever release them.

Call ov5647_power_off() in that case, guarded by pm_runtime_status_suspended() so the common already-suspended case isn't suspended twice -- same guard sibling imx412.c's remove() uses.

Fixes 3c2472a3c548 ("[media] media: i2c: Add support for OV5647 sensor")
Assisted-by LLM
---
 drivers/media/i2c/ov5647.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/i2c/ov5647.c +2 -0
index 3facf92b3841..52124327959a 100644
@@ -1271,6 +1271,8 @@ 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);
 }
 
 static const struct dev_pm_ops ov5647_pm_ops = {
Signature · 1 line
2.25.1