Skip to contentSkip to conversation

media: i2c: Add missing v4l2_subdev_cleanup() calls

PATCH In review Aleksandr Chubuchnyi 3 participants 8 messages Sep 9 – Sep 21

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

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
#1 lore raw

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.

Fixes cb33db2b6ccf ("media: i2c: IMX296 camera sensor driver")
---
 drivers/media/i2c/imx296.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/i2c/imx296.c +1 -0
index 69636db11..855137b5a 100644
@@ -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
#2 lore raw

PATCH 2/5 media: i2c: imx415: Add missing v4l2_subdev_cleanup() call

In reply to 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")
---
 drivers/media/i2c/imx415.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/i2c/imx415.c +1 -0
index c3b22b238..12c2f3df6 100644
@@ -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
maintainer Reviewed-by on v1 2/5
#3 lore raw

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")

Best regards,
Michael

Quoted 16 lines
---
 drivers/media/i2c/imx415.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/i2c/imx415.c +1 -0
index c3b22b238..12c2f3df6 100644
@@ -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);
 }
#4 lore raw

PATCH 3/5 media: i2c: mt9m114: Add missing v4l2_subdev_cleanup() calls

In reply to Aleksandr Chubuchnyi

The subdev active state allocated by v4l2_subdev_init_finalize() is leaked on unbind, for both the pixel array and the image flow processor subdev.

Fixes 24d756e914fc ("media: i2c: Add driver for onsemi MT9M114 camera sensor")
---
 drivers/media/i2c/mt9m114.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/i2c/mt9m114.c +2 -0
index 848ea06e7..137e8e6df 100644
@@ -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
#5 lore raw

PATCH 4/5 media: i2c: ov8858: Add missing v4l2_subdev_cleanup() call

In reply to Aleksandr Chubuchnyi

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 e14d3ac81bd2 ("media: i2c: Add driver for OmniVision OV8858")
---
 drivers/media/i2c/ov8858.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/i2c/ov8858.c +2 -0
index 3f45f7fab..2076620c7 100644
@@ -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
#6 lore raw

PATCH 5/5 media: i2c: st-mipid02: Add missing v4l2_subdev_cleanup() call

In reply to Aleksandr Chubuchnyi

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")
---
 drivers/media/i2c/st-mipid02.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/i2c/st-mipid02.c +2 -0
index 4675181af..b2f275129 100644
@@ -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
maintainer Reviewed-by on v1 5/5
#7 lore raw

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")
---
 drivers/media/i2c/st-mipid02.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/i2c/st-mipid02.c +2 -0
index 4675181af..b2f275129 100644
@@ -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