[PATCH 04/22] media: i2c: mt9v011: Add missing media_entity_cleanup()
From: Biren Pandya
Date: Sun Jun 14 2026 - 12:57:05 EST
The media_entity_pads_init() function initializes the media entity, but
the driver forgets to call media_entity_cleanup() in the error paths
and remove function. Add the missing calls to fix the API violation and
prevent potential future memory leaks.
Signed-off-by: Biren Pandya <birenpandya@xxxxxxxxx>
---
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)