media: i2c: ov2740: fix power leak on remove while runtime-active
PATCH 1/1 media: i2c: ov2740: fix power leak on remove while runtime-active
ov2740_remove() calls pm_runtime_disable() and nothing else -- it never calls ov2740_suspend(), which actually powers the sensor down (asserts reset/powerdown gpios, disables the clock, 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 regulators, clock and gpios stay in their active state with no code path left to ever release them.
Call ov2740_suspend() 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.
Moved remove() after suspend()/resume()'s definitions since it now calls them directly.
--- drivers/media/i2c/ov2740.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/media/i2c/ov2740.c +13 -11
@@ -1198,17 +1198,6 @@ static int ov2740_check_hwcfg(struct ov2740 *ov2740)return ret; } -static void ov2740_remove (struct i2c_client *client) -{ -struct v4l2_subdev *sd =i2c_get_clientdata (client); - -v4l2_async_unregister_subdev (sd); -media_entity_cleanup (&sd->entity); -v4l2_subdev_cleanup (sd); -v4l2_ctrl_handler_free (sd->ctrl_handler); -pm_runtime_disable (&client->dev); -} -static int ov2740_nvmem_read (void *priv,unsigned int off,void *val,size_t count) {
@@ -1323,6 +1312,19 @@ static int ov2740_resume(struct device *dev)return 0 ; } +static void ov2740_remove (struct i2c_client *client) +{ +struct v4l2_subdev *sd =i2c_get_clientdata (client); + +v4l2_async_unregister_subdev (sd); +media_entity_cleanup (&sd->entity); +v4l2_subdev_cleanup (sd); +v4l2_ctrl_handler_free (sd->ctrl_handler); +pm_runtime_disable (&client->dev); +if (!pm_runtime_status_suspended (&client->dev)) +ov2740_suspend (&client->dev); +} +static int ov2740_probe (struct i2c_client *client) {struct device *dev = &client->dev;
Signature · 1 line
2.25.1