* [PATCH 1/5] media: i2c: cx25840-core: Add missing media_entity_cleanup()
2026-06-19 10:01 [PATCH 0/5] media: i2c: Add missing media_entity_cleanup() calls Biren Pandya
@ 2026-06-19 10:01 ` Biren Pandya
2026-06-19 10:01 ` [PATCH 2/5] media: i2c: max9286: " Biren Pandya
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Biren Pandya @ 2026-06-19 10:01 UTC (permalink / raw)
To: linux-media
Cc: Biren Pandya, Mauro Carvalho Chehab, Hans Verkuil, Bradford Love
The probe error paths and remove function are missing calls to
media_entity_cleanup(). Add them to prevent memory leaks if pads
are dynamically allocated.
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 related [flat|nested] 8+ messages in thread* [PATCH 2/5] media: i2c: max9286: Add missing media_entity_cleanup()
2026-06-19 10:01 [PATCH 0/5] media: i2c: Add missing media_entity_cleanup() calls Biren Pandya
2026-06-19 10:01 ` [PATCH 1/5] media: i2c: cx25840-core: Add missing media_entity_cleanup() Biren Pandya
@ 2026-06-19 10:01 ` Biren Pandya
2026-06-22 8:29 ` Jacopo Mondi
2026-06-19 10:01 ` [PATCH 3/5] media: i2c: msp3400-driver: " Biren Pandya
` (2 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Biren Pandya @ 2026-06-19 10:01 UTC (permalink / raw)
To: linux-media
Cc: Biren Pandya, Jacopo Mondi, Kieran Bingham, Laurent Pinchart,
Niklas Söderlund, Mauro Carvalho Chehab
The probe error paths and unregister function are missing calls to
media_entity_cleanup(). Add them to prevent memory leaks if pads
are dynamically allocated.
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 related [flat|nested] 8+ messages in thread* Re: [PATCH 2/5] media: i2c: max9286: Add missing media_entity_cleanup()
2026-06-19 10:01 ` [PATCH 2/5] media: i2c: max9286: " Biren Pandya
@ 2026-06-22 8:29 ` Jacopo Mondi
0 siblings, 0 replies; 8+ messages in thread
From: Jacopo Mondi @ 2026-06-22 8:29 UTC (permalink / raw)
To: Biren Pandya
Cc: linux-media, Jacopo Mondi, Kieran Bingham, Laurent Pinchart,
Niklas Söderlund, Mauro Carvalho Chehab
Hi Biren
On Fri, Jun 19, 2026 at 03:31:29PM +0530, Biren Pandya wrote:
> The probe error paths and unregister function are missing calls to
> media_entity_cleanup(). Add them to prevent memory leaks if pads
> are dynamically allocated.
I think the last phrase can be dropped. media_entity_cleanup() is a
nop.
>
> Signed-off-by: Biren Pandya <birenpandya@gmail.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.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] 8+ messages in thread
* [PATCH 3/5] media: i2c: msp3400-driver: Add missing media_entity_cleanup()
2026-06-19 10:01 [PATCH 0/5] media: i2c: Add missing media_entity_cleanup() calls Biren Pandya
2026-06-19 10:01 ` [PATCH 1/5] media: i2c: cx25840-core: Add missing media_entity_cleanup() Biren Pandya
2026-06-19 10:01 ` [PATCH 2/5] media: i2c: max9286: " Biren Pandya
@ 2026-06-19 10:01 ` Biren Pandya
2026-06-22 8:34 ` Jacopo Mondi
2026-06-19 10:01 ` [PATCH 4/5] media: i2c: mt9v011: " Biren Pandya
2026-06-19 10:01 ` [PATCH 5/5] media: i2c: saa7115: " Biren Pandya
4 siblings, 1 reply; 8+ messages in thread
From: Biren Pandya @ 2026-06-19 10:01 UTC (permalink / raw)
To: linux-media; +Cc: Biren Pandya, Mauro Carvalho Chehab
The probe error paths and remove function are missing calls to
media_entity_cleanup(). Add them to prevent memory leaks if pads
are dynamically allocated.
Signed-off-by: Biren Pandya <birenpandya@gmail.com>
---
drivers/media/i2c/msp3400-driver.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/media/i2c/msp3400-driver.c b/drivers/media/i2c/msp3400-driver.c
index 4c0b0ad68c08..d977a6039e6c 100644
--- a/drivers/media/i2c/msp3400-driver.c
+++ b/drivers/media/i2c/msp3400-driver.c
@@ -812,6 +812,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 +866,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 related [flat|nested] 8+ messages in thread
* Re: [PATCH 3/5] media: i2c: msp3400-driver: Add missing media_entity_cleanup()
2026-06-19 10:01 ` [PATCH 3/5] media: i2c: msp3400-driver: " Biren Pandya
@ 2026-06-22 8:34 ` Jacopo Mondi
0 siblings, 0 replies; 8+ messages in thread
From: Jacopo Mondi @ 2026-06-22 8:34 UTC (permalink / raw)
To: Biren Pandya; +Cc: linux-media, Mauro Carvalho Chehab
Hi Biren
On Fri, Jun 19, 2026 at 03:31:30PM +0530, Biren Pandya wrote:
> The probe error paths and remove function are missing calls to
> media_entity_cleanup(). Add them to prevent memory leaks if pads
> are dynamically allocated.
>
> Signed-off-by: Biren Pandya <birenpandya@gmail.com>
> ---
> drivers/media/i2c/msp3400-driver.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/media/i2c/msp3400-driver.c b/drivers/media/i2c/msp3400-driver.c
> index 4c0b0ad68c08..d977a6039e6c 100644
> --- a/drivers/media/i2c/msp3400-driver.c
> +++ b/drivers/media/i2c/msp3400-driver.c
> @@ -812,6 +812,7 @@ static int msp_probe(struct i2c_client *client)
> int err = hdl->error;
>
> v4l2_ctrl_handler_free(hdl);
> + media_entity_cleanup(&sd->entity);
This driver really seems a relic from the past, but if you want to add
media_entity_cleanup() to it, there is one previous error path after
media_entity_pads_init() where you might want to do that.
> return err;
> }
>
> @@ -865,6 +866,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] 8+ messages in thread
* [PATCH 4/5] media: i2c: mt9v011: Add missing media_entity_cleanup()
2026-06-19 10:01 [PATCH 0/5] media: i2c: Add missing media_entity_cleanup() calls Biren Pandya
` (2 preceding siblings ...)
2026-06-19 10:01 ` [PATCH 3/5] media: i2c: msp3400-driver: " Biren Pandya
@ 2026-06-19 10:01 ` Biren Pandya
2026-06-19 10:01 ` [PATCH 5/5] media: i2c: saa7115: " Biren Pandya
4 siblings, 0 replies; 8+ messages in thread
From: Biren Pandya @ 2026-06-19 10:01 UTC (permalink / raw)
To: linux-media; +Cc: Biren Pandya, Sakari Ailus, Mauro Carvalho Chehab
The probe error paths and remove function are missing calls to
media_entity_cleanup(). Add them to prevent memory leaks if pads
are dynamically allocated.
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 related [flat|nested] 8+ messages in thread* [PATCH 5/5] media: i2c: saa7115: Add missing media_entity_cleanup()
2026-06-19 10:01 [PATCH 0/5] media: i2c: Add missing media_entity_cleanup() calls Biren Pandya
` (3 preceding siblings ...)
2026-06-19 10:01 ` [PATCH 4/5] media: i2c: mt9v011: " Biren Pandya
@ 2026-06-19 10:01 ` Biren Pandya
4 siblings, 0 replies; 8+ messages in thread
From: Biren Pandya @ 2026-06-19 10:01 UTC (permalink / raw)
To: linux-media; +Cc: Biren Pandya, Mauro Carvalho Chehab, Hans Verkuil
The probe error paths and remove function are missing calls to
media_entity_cleanup(). Add them to prevent memory leaks if pads
are dynamically allocated.
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 related [flat|nested] 8+ messages in thread