media: i2c: Add missing v4l2_subdev_cleanup() calls
Subsystems (8)
cover media: i2c: Add missing v4l2_subdev_cleanup() calls
v4l2_subdev_init_finalize() allocates the subdev active state and only v4l2_subdev_cleanup() frees it. These five drivers never call it, so they leak the state on every unbind.
Separate patches because the Fixes tags span 2022 to 2023 and go to different stable trees. The st-mipid02 one dates from the active state conversion, not from the original driver.
Aleksandr Chubuchnyi (5):
media: i2c: imx296: Add missing v4l2_subdev_cleanup() call
media: i2c: imx415: Add missing v4l2_subdev_cleanup() call
media: i2c: mt9m114: Add missing v4l2_subdev_cleanup() calls
media: i2c: ov8858: Add missing v4l2_subdev_cleanup() call
media: i2c: st-mipid02: Add missing v4l2_subdev_cleanup() call
drivers/media/i2c/imx296.c | 1 + drivers/media/i2c/imx415.c | 1 + drivers/media/i2c/mt9m114.c | 2 ++ drivers/media/i2c/ov8858.c | 2 ++ drivers/media/i2c/st-mipid02.c | 2 ++ 5 files changed, 8 insertions(+)
Signature · 1 line
2.43.0
PATCH 1/5 media: i2c: imx296: Add missing v4l2_subdev_cleanup() call
The subdev active state allocated by v4l2_subdev_init_finalize() is leaked on unbind.
--- drivers/media/i2c/imx296.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/i2c/imx296.c +1 -0
@@ -870,6 +870,7 @@ static int imx296_subdev_init(struct imx296 *sensor)static void imx296_subdev_cleanup (struct imx296 *sensor) { +v4l2_subdev_cleanup (&sensor->subdev);media_entity_cleanup (&sensor->subdev.entity);v4l2_ctrl_handler_free (&sensor->ctrls); }
Signature · 1 line
2.43.0
PATCH 2/5 media: i2c: imx415: Add missing v4l2_subdev_cleanup() call
In reply to Aleksandr ChubuchnyiThe subdev active state allocated by v4l2_subdev_init_finalize() is leaked on unbind.
--- drivers/media/i2c/imx415.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/i2c/imx415.c +1 -0
@@ -1125,6 +1125,7 @@ static int imx415_subdev_init(struct imx415 *sensor)static void imx415_subdev_cleanup (struct imx415 *sensor) { +v4l2_subdev_cleanup (&sensor->subdev);media_entity_cleanup (&sensor->subdev.entity);v4l2_ctrl_handler_free (&sensor->ctrls); }
Signature · 1 line
2.43.0
Re: [PATCH 2/5] media: i2c: imx415: Add missing v4l2_subdev_cleanup() call
Hi Aleksandr,
Thanks for the patch, LGTM!
Quoted 6 lines · Aleksandr Chubuchnyi
The subdev active state allocated by
v4l2_subdev_init_finalize()is leaked on unbind.Fixes 14cd15e7a1e2 ("media: i2c: add imx415 cmos image sensor driver")Signed-off-by Aleksandr Chubuchnyi <[email protected]>
Best regards,
Michael
Quoted 16 lines
--- drivers/media/i2c/imx415.c | 1 + 1 file changed, 1 insertion(+)drivers/media/i2c/imx415.c +1
-0@@ -1125,6 +1125,7 @@ static int imx415_subdev_init(struct imx415 *sensor)static void imx415_subdev_cleanup (struct imx415 *sensor) { +v4l2_subdev_cleanup (&sensor->subdev);media_entity_cleanup (&sensor->subdev.entity);v4l2_ctrl_handler_free (&sensor->ctrls); }
PATCH 3/5 media: i2c: mt9m114: Add missing v4l2_subdev_cleanup() calls
In reply to Aleksandr ChubuchnyiThe subdev active state allocated by v4l2_subdev_init_finalize() is leaked on unbind, for both the pixel array and the image flow processor subdev.
--- drivers/media/i2c/mt9m114.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/i2c/mt9m114.c +2 -0
@@ -1482,6 +1482,7 @@ static int mt9m114_pa_init(struct mt9m114 *sensor)static void mt9m114_pa_cleanup (struct mt9m114 *sensor) { +v4l2_subdev_cleanup (&sensor->pa.sd);v4l2_ctrl_handler_free (&sensor->pa.hdl);media_entity_cleanup (&sensor->pa.sd.entity); }
@@ -2208,6 +2209,7 @@ static int mt9m114_ifp_init(struct mt9m114 *sensor)static void mt9m114_ifp_cleanup (struct mt9m114 *sensor) { +v4l2_subdev_cleanup (&sensor->ifp.sd);v4l2_ctrl_handler_free (&sensor->ifp.hdl);media_entity_cleanup (&sensor->ifp.sd.entity); }
Signature · 1 line
2.43.0
PATCH 4/5 media: i2c: ov8858: Add missing v4l2_subdev_cleanup() call
In reply to Aleksandr ChubuchnyiThe subdev active state allocated by v4l2_subdev_init_finalize() is leaked on unbind. The driver has no common cleanup helper, so update both sites.
--- drivers/media/i2c/ov8858.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/i2c/ov8858.c +2 -0
@@ -1953,6 +1953,7 @@ static int ov8858_probe(struct i2c_client *client)pm_runtime_put_noidle (dev);ov8858_power_off (ov8858); err_clean_entity: +v4l2_subdev_cleanup (sd);media_entity_cleanup (&sd->entity); err_free_handler:v4l2_ctrl_handler_free (&ov8858->ctrl_handler);
@@ -1966,6 +1967,7 @@ static void ov8858_remove(struct i2c_client *client)struct ov8858 *ov8858 =sd_to_ov8858 (sd);v4l2_async_unregister_subdev (sd); +v4l2_subdev_cleanup (sd);media_entity_cleanup (&sd->entity);v4l2_ctrl_handler_free (&ov8858->ctrl_handler);
Signature · 1 line
2.43.0
PATCH 5/5 media: i2c: st-mipid02: Add missing v4l2_subdev_cleanup() call
In reply to Aleksandr ChubuchnyiThe subdev active state allocated by v4l2_subdev_init_finalize() is leaked on unbind. The driver has no common cleanup helper, so update both sites.
--- drivers/media/i2c/st-mipid02.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/i2c/st-mipid02.c +2 -0
@@ -919,6 +919,7 @@ static int mipid02_probe(struct i2c_client *client) power_off:mipid02_set_power_off (&client->dev); entity_cleanup: +v4l2_subdev_cleanup (&bridge->sd);media_entity_cleanup (&bridge->sd.entity);return ret;
@@ -937,6 +938,7 @@ static void mipid02_remove(struct i2c_client *client)if (!pm_runtime_status_suspended (&client->dev))mipid02_set_power_off (&client->dev);pm_runtime_set_suspended (&client->dev); +v4l2_subdev_cleanup (&bridge->sd);media_entity_cleanup (&bridge->sd.entity); }
Signature · 1 line
2.43.0
Re: [PATCH 5/5] media: i2c: st-mipid02: Add missing v4l2_subdev_cleanup() call
Hi,
Thanks, LGTM.
Le 09/09/2026 à 10:02, Aleksandr Chubuchnyi a écrit :
Quoted 30 lines
The subdev active state allocated by
v4l2_subdev_init_finalize()is leaked on unbind. The driver has no common cleanup helper, so update both sites.Fixes 04d170b288b3 ("media: i2c: st-mipid02: use active state to store pad formats")Signed-off-by Aleksandr Chubuchnyi <[email protected]>--- drivers/media/i2c/st-mipid02.c | 2 ++ 1 file changed, 2 insertions(+)drivers/media/i2c/st-mipid02.c +2
-0@@ -919,6 +919,7 @@ static int mipid02_probe(struct i2c_client *client) power_off:mipid02_set_power_off (&client->dev); entity_cleanup: +v4l2_subdev_cleanup (&bridge->sd);media_entity_cleanup (&bridge->sd.entity);return ret;@@ -937,6 +938,7 @@ static void mipid02_remove(struct i2c_client *client)if (!pm_runtime_status_suspended (&client->dev))mipid02_set_power_off (&client->dev);pm_runtime_set_suspended (&client->dev); +v4l2_subdev_cleanup (&bridge->sd);media_entity_cleanup (&bridge->sd.entity); }
Signature · 2 lines
Regards, Benjamin