mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/5] media: i2c: Add missing media_entity_cleanup()
@ 2026-07-15  3:38 Biren Pandya
  2026-07-15  3:38 ` [PATCH v2 1/5] media: i2c: cx25840-core: " Biren Pandya
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Biren Pandya @ 2026-07-15  3:38 UTC (permalink / raw)
  To: mchehab, jacopo+renesas, kieran.bingham+renesas,
	laurent.pinchart+renesas, Niklas Söderlund, sakari.ailus,
	linux-media, linux-kernel
  Cc: Biren Pandya


This series adds missing media_entity_cleanup() calls to the remove
functions of several media I2C drivers that initialize media entity pads
in their probe functions.

This is part of a larger effort to fix missing media_entity_cleanup()
calls across the media subsystem. Previously sent as a monolithic
tree-wide patch, this has been split into directory-scoped series
to keep review manageable.

Changes in v2:
- Dropped "prevent memory leaks" from commit messages since
  media_entity_cleanup() is currently a no-op. (Jacopo)
- Added missing cleanup to the probe error path in msp3400-driver. (Jacopo)
- Added Reviewed-by tag to max9286 patch.

Biren Pandya (5):
  media: i2c: cx25840-core: Add missing media_entity_cleanup()
  media: i2c: max9286: Add missing media_entity_cleanup()
  media: i2c: msp3400-driver: Add missing media_entity_cleanup()
  media: i2c: mt9v011: Add missing media_entity_cleanup()
  media: i2c: saa7115: Add missing media_entity_cleanup()

 drivers/media/i2c/cx25840/cx25840-core.c | 2 ++
 drivers/media/i2c/max9286.c              | 5 ++++-
 drivers/media/i2c/msp3400-driver.c       | 3 +++
 drivers/media/i2c/mt9v011.c              | 3 +++
 drivers/media/i2c/saa7115.c              | 2 ++
 5 files changed, 14 insertions(+), 1 deletion(-)

-- 
2.50.1 (Apple Git-155)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/5] media: i2c: cx25840-core: Add missing media_entity_cleanup()
  2026-07-15  3:38 [PATCH v2 0/5] media: i2c: Add missing media_entity_cleanup() Biren Pandya
@ 2026-07-15  3:38 ` Biren Pandya
  2026-07-15  3:38 ` [PATCH v2 2/5] media: i2c: max9286: " Biren Pandya
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Biren Pandya @ 2026-07-15  3:38 UTC (permalink / raw)
  To: mchehab, jacopo+renesas, kieran.bingham+renesas,
	laurent.pinchart+renesas, Niklas Söderlund, sakari.ailus,
	linux-media, linux-kernel
  Cc: Biren Pandya

The remove function is missing a call to media_entity_cleanup(). Add it.

Signed-off-by: Biren Pandya <birenpandya@gmail.com>
---
 drivers/media/i2c/cx25840/cx25840-core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
index 69d5cc648c0f..a3d7473854a3 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -3962,6 +3962,7 @@ static int cx25840_probe(struct i2c_client *client)
 		int err = state->hdl.error;
 
 		v4l2_ctrl_handler_free(&state->hdl);
+		media_entity_cleanup(&sd->entity);
 		return err;
 	}
 	if (!is_cx2583x(state))
@@ -3986,6 +3987,7 @@ static void cx25840_remove(struct i2c_client *client)
 	cx25840_ir_remove(sd);
 	v4l2_device_unregister_subdev(sd);
 	v4l2_ctrl_handler_free(&state->hdl);
+	media_entity_cleanup(&sd->entity);
 }
 
 static const struct i2c_device_id cx25840_id[] = {
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 2/5] media: i2c: max9286: Add missing media_entity_cleanup()
  2026-07-15  3:38 [PATCH v2 0/5] media: i2c: Add missing media_entity_cleanup() Biren Pandya
  2026-07-15  3:38 ` [PATCH v2 1/5] media: i2c: cx25840-core: " Biren Pandya
@ 2026-07-15  3:38 ` Biren Pandya
  2026-07-15  3:38 ` [PATCH v2 3/5] media: i2c: msp3400-driver: " Biren Pandya
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Biren Pandya @ 2026-07-15  3:38 UTC (permalink / raw)
  To: mchehab, jacopo+renesas, kieran.bingham+renesas,
	laurent.pinchart+renesas, Niklas Söderlund, sakari.ailus,
	linux-media, linux-kernel
  Cc: Biren Pandya, Jacopo Mondi

The remove function is missing a call to media_entity_cleanup(). Add it.

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Biren Pandya <birenpandya@gmail.com>
---
 drivers/media/i2c/max9286.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
index ac0712ce1e65..79eab9045e24 100644
--- a/drivers/media/i2c/max9286.c
+++ b/drivers/media/i2c/max9286.c
@@ -1062,7 +1062,7 @@ static int max9286_v4l2_register(struct max9286_priv *priv)
 	priv->sd.state_lock = priv->ctrls.lock;
 	ret = v4l2_subdev_init_finalize(&priv->sd);
 	if (ret)
-		goto err_async;
+		goto err_entity;
 
 	ret = v4l2_async_register_subdev(&priv->sd);
 	if (ret < 0) {
@@ -1074,6 +1074,8 @@ static int max9286_v4l2_register(struct max9286_priv *priv)
 
 err_subdev:
 	v4l2_subdev_cleanup(&priv->sd);
+err_entity:
+	media_entity_cleanup(&priv->sd.entity);
 err_async:
 	v4l2_ctrl_handler_free(&priv->ctrls);
 	max9286_v4l2_notifier_unregister(priv);
@@ -1084,6 +1086,7 @@ static int max9286_v4l2_register(struct max9286_priv *priv)
 static void max9286_v4l2_unregister(struct max9286_priv *priv)
 {
 	v4l2_subdev_cleanup(&priv->sd);
+	media_entity_cleanup(&priv->sd.entity);
 	v4l2_ctrl_handler_free(&priv->ctrls);
 	v4l2_async_unregister_subdev(&priv->sd);
 	max9286_v4l2_notifier_unregister(priv);
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 3/5] media: i2c: msp3400-driver: Add missing media_entity_cleanup()
  2026-07-15  3:38 [PATCH v2 0/5] media: i2c: Add missing media_entity_cleanup() Biren Pandya
  2026-07-15  3:38 ` [PATCH v2 1/5] media: i2c: cx25840-core: " Biren Pandya
  2026-07-15  3:38 ` [PATCH v2 2/5] media: i2c: max9286: " Biren Pandya
@ 2026-07-15  3:38 ` Biren Pandya
  2026-07-15  3:38 ` [PATCH v2 4/5] media: i2c: mt9v011: " Biren Pandya
  2026-07-15  3:38 ` [PATCH v2 5/5] media: i2c: saa7115: " Biren Pandya
  4 siblings, 0 replies; 7+ messages in thread
From: Biren Pandya @ 2026-07-15  3:38 UTC (permalink / raw)
  To: mchehab, jacopo+renesas, kieran.bingham+renesas,
	laurent.pinchart+renesas, Niklas Söderlund, sakari.ailus,
	linux-media, linux-kernel
  Cc: Biren Pandya

The remove function and the probe error path are missing calls to
media_entity_cleanup(). Add them.

Signed-off-by: Biren Pandya <birenpandya@gmail.com>
---
 drivers/media/i2c/msp3400-driver.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/i2c/msp3400-driver.c b/drivers/media/i2c/msp3400-driver.c
index 4c0b0ad68c08..48c60050c5d7 100644
--- a/drivers/media/i2c/msp3400-driver.c
+++ b/drivers/media/i2c/msp3400-driver.c
@@ -717,6 +717,7 @@ static int msp_probe(struct i2c_client *client)
 	if (state->rev1 == -1 || (state->rev1 == 0 && state->rev2 == 0)) {
 		dev_dbg_lvl(&client->dev, 1, msp_debug,
 				"not an msp3400 (cannot read chip version)\n");
+		media_entity_cleanup(&sd->entity);
 		return -ENODEV;
 	}
 
@@ -812,6 +813,7 @@ static int msp_probe(struct i2c_client *client)
 		int err = hdl->error;
 
 		v4l2_ctrl_handler_free(hdl);
+		media_entity_cleanup(&sd->entity);
 		return err;
 	}
 
@@ -865,6 +867,7 @@ static void msp_remove(struct i2c_client *client)
 	msp_reset(client);
 
 	v4l2_ctrl_handler_free(&state->hdl);
+	media_entity_cleanup(&state->sd.entity);
 }
 
 /* ----------------------------------------------------------------------- */
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 4/5] media: i2c: mt9v011: Add missing media_entity_cleanup()
  2026-07-15  3:38 [PATCH v2 0/5] media: i2c: Add missing media_entity_cleanup() Biren Pandya
                   ` (2 preceding siblings ...)
  2026-07-15  3:38 ` [PATCH v2 3/5] media: i2c: msp3400-driver: " Biren Pandya
@ 2026-07-15  3:38 ` Biren Pandya
  2026-07-15  3:38 ` [PATCH v2 5/5] media: i2c: saa7115: " Biren Pandya
  4 siblings, 0 replies; 7+ messages in thread
From: Biren Pandya @ 2026-07-15  3:38 UTC (permalink / raw)
  To: mchehab, jacopo+renesas, kieran.bingham+renesas,
	laurent.pinchart+renesas, Niklas Söderlund, sakari.ailus,
	linux-media, linux-kernel
  Cc: Biren Pandya

The remove function is missing a call to media_entity_cleanup(). Add it.

Signed-off-by: Biren Pandya <birenpandya@gmail.com>
---
 drivers/media/i2c/mt9v011.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/i2c/mt9v011.c b/drivers/media/i2c/mt9v011.c
index 055b7915260a..b7ef8bff727d 100644
--- a/drivers/media/i2c/mt9v011.c
+++ b/drivers/media/i2c/mt9v011.c
@@ -520,6 +520,7 @@ static int mt9v011_probe(struct i2c_client *c)
 	    (version != MT9V011_REV_B_VERSION)) {
 		v4l2_info(sd, "*** unknown micron chip detected (0x%04x).\n",
 			  version);
+		media_entity_cleanup(&sd->entity);
 		return -EINVAL;
 	}
 
@@ -542,6 +543,7 @@ static int mt9v011_probe(struct i2c_client *c)
 
 		v4l2_err(sd, "control initialization error %d\n", ret);
 		v4l2_ctrl_handler_free(&core->ctrls);
+		media_entity_cleanup(&sd->entity);
 		return ret;
 	}
 	core->sd.ctrl_handler = &core->ctrls;
@@ -577,6 +579,7 @@ static void mt9v011_remove(struct i2c_client *c)
 
 	v4l2_device_unregister_subdev(sd);
 	v4l2_ctrl_handler_free(&core->ctrls);
+	media_entity_cleanup(&sd->entity);
 }
 
 /* ----------------------------------------------------------------------- */
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 5/5] media: i2c: saa7115: Add missing media_entity_cleanup()
  2026-07-15  3:38 [PATCH v2 0/5] media: i2c: Add missing media_entity_cleanup() Biren Pandya
                   ` (3 preceding siblings ...)
  2026-07-15  3:38 ` [PATCH v2 4/5] media: i2c: mt9v011: " Biren Pandya
@ 2026-07-15  3:38 ` Biren Pandya
  4 siblings, 0 replies; 7+ messages in thread
From: Biren Pandya @ 2026-07-15  3:38 UTC (permalink / raw)
  To: mchehab, jacopo+renesas, kieran.bingham+renesas,
	laurent.pinchart+renesas, Niklas Söderlund, sakari.ailus,
	linux-media, linux-kernel
  Cc: Biren Pandya

The remove function is missing a call to media_entity_cleanup(). Add it.

Signed-off-by: Biren Pandya <birenpandya@gmail.com>
---
 drivers/media/i2c/saa7115.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c
index 48d6730d9271..64adfff3001b 100644
--- a/drivers/media/i2c/saa7115.c
+++ b/drivers/media/i2c/saa7115.c
@@ -1867,6 +1867,7 @@ static int saa711x_probe(struct i2c_client *client)
 		int err = hdl->error;
 
 		v4l2_ctrl_handler_free(hdl);
+		media_entity_cleanup(&sd->entity);
 		return err;
 	}
 	v4l2_ctrl_auto_cluster(2, &state->agc, 0, true);
@@ -1925,6 +1926,7 @@ static void saa711x_remove(struct i2c_client *client)
 
 	v4l2_device_unregister_subdev(sd);
 	v4l2_ctrl_handler_free(sd->ctrl_handler);
+	media_entity_cleanup(&sd->entity);
 }
 
 static const struct i2c_device_id saa711x_id[] = {
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 2/5] media: i2c: max9286: Add missing media_entity_cleanup()
  2026-06-22 18:48 [PATCH v2 0/5] media: i2c: " Biren Pandya
@ 2026-06-22 18:48 ` Biren Pandya
  0 siblings, 0 replies; 7+ messages in thread
From: Biren Pandya @ 2026-06-22 18:48 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media
  Cc: Jacopo Mondi, Kieran Bingham, Laurent Pinchart,
	Niklas Söderlund, Sakari Ailus, linux-kernel, birenpandya,
	Jacopo Mondi

The remove function is missing a call to media_entity_cleanup(). Add it.

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Biren Pandya <birenpandya@gmail.com>
---
 drivers/media/i2c/max9286.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
index ac0712ce1e65..79eab9045e24 100644
--- a/drivers/media/i2c/max9286.c
+++ b/drivers/media/i2c/max9286.c
@@ -1062,7 +1062,7 @@ static int max9286_v4l2_register(struct max9286_priv *priv)
 	priv->sd.state_lock = priv->ctrls.lock;
 	ret = v4l2_subdev_init_finalize(&priv->sd);
 	if (ret)
-		goto err_async;
+		goto err_entity;
 
 	ret = v4l2_async_register_subdev(&priv->sd);
 	if (ret < 0) {
@@ -1074,6 +1074,8 @@ static int max9286_v4l2_register(struct max9286_priv *priv)
 
 err_subdev:
 	v4l2_subdev_cleanup(&priv->sd);
+err_entity:
+	media_entity_cleanup(&priv->sd.entity);
 err_async:
 	v4l2_ctrl_handler_free(&priv->ctrls);
 	max9286_v4l2_notifier_unregister(priv);
@@ -1084,6 +1086,7 @@ static int max9286_v4l2_register(struct max9286_priv *priv)
 static void max9286_v4l2_unregister(struct max9286_priv *priv)
 {
 	v4l2_subdev_cleanup(&priv->sd);
+	media_entity_cleanup(&priv->sd.entity);
 	v4l2_ctrl_handler_free(&priv->ctrls);
 	v4l2_async_unregister_subdev(&priv->sd);
 	max9286_v4l2_notifier_unregister(priv);
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-07-15  3:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-15  3:38 [PATCH v2 0/5] media: i2c: Add missing media_entity_cleanup() Biren Pandya
2026-07-15  3:38 ` [PATCH v2 1/5] media: i2c: cx25840-core: " Biren Pandya
2026-07-15  3:38 ` [PATCH v2 2/5] media: i2c: max9286: " Biren Pandya
2026-07-15  3:38 ` [PATCH v2 3/5] media: i2c: msp3400-driver: " Biren Pandya
2026-07-15  3:38 ` [PATCH v2 4/5] media: i2c: mt9v011: " Biren Pandya
2026-07-15  3:38 ` [PATCH v2 5/5] media: i2c: saa7115: " Biren Pandya
  -- strict thread matches above, loose matches on Subject: below --
2026-06-22 18:48 [PATCH v2 0/5] media: i2c: " Biren Pandya
2026-06-22 18:48 ` [PATCH v2 2/5] media: i2c: max9286: " Biren Pandya

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®