[PATCH 02/22] media: i2c: max9286: Add missing media_entity_cleanup()

From: Biren Pandya

Date: Sun Jun 14 2026 - 12:57:38 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.

Fixes: 66d8c9d2422d ("media: i2c: Add MAX9286 driver")
Signed-off-by: Biren Pandya <birenpandya@xxxxxxxxx>
---
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..31598fa34c6c 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);
@@ -1087,6 +1089,7 @@ static void max9286_v4l2_unregister(struct max9286_priv *priv)
v4l2_ctrl_handler_free(&priv->ctrls);
v4l2_async_unregister_subdev(&priv->sd);
max9286_v4l2_notifier_unregister(priv);
+ media_entity_cleanup(&priv->sd.entity);
}

/* -----------------------------------------------------------------------------
--
2.50.1 (Apple Git-155)