Skip to contentSkip to conversation

media: i2c: Add missing media_entity_cleanup()

PATCH Superseded Biren Pandya 1 participant 6 messages Jun 22

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

v2 cover media: i2c: Add missing media_entity_cleanup()

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.

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(-)
Signature · 1 line
2.50.1 (Apple Git-155)
#1 lore raw

PATCH v2 1/5 media: i2c: cx25840-core: Add missing media_entity_cleanup()

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

---
 drivers/media/i2c/cx25840/cx25840-core.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/i2c/cx25840/cx25840-core.c +2 -0
index 69d5cc648c0f..a3d7473854a3 100644
@@ -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[] = {
Signature · 1 line
2.50.1 (Apple Git-155)
#2 lore raw

PATCH v2 2/5 media: i2c: max9286: Add missing media_entity_cleanup()

In reply to Biren Pandya

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

---
 drivers/media/i2c/max9286.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/i2c/max9286.c +4 -1
index ac0712ce1e65..79eab9045e24 100644
@@ -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);
Signature · 1 line
2.50.1 (Apple Git-155)
#3 lore raw

PATCH v2 3/5 media: i2c: msp3400-driver: Add missing media_entity_cleanup()

In reply to Biren Pandya

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

---
 drivers/media/i2c/msp3400-driver.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/media/i2c/msp3400-driver.c +3 -0
index 4c0b0ad68c08..48c60050c5d7 100644
@@ -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);
 }
 
 /* ----------------------------------------------------------------------- */
Signature · 1 line
2.50.1 (Apple Git-155)
#4 lore raw

PATCH v2 4/5 media: i2c: mt9v011: Add missing media_entity_cleanup()

In reply to Biren Pandya

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

---
 drivers/media/i2c/mt9v011.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/media/i2c/mt9v011.c +3 -0
index 055b7915260a..b7ef8bff727d 100644
@@ -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);
 }
 
 /* ----------------------------------------------------------------------- */
Signature · 1 line
2.50.1 (Apple Git-155)
#5 lore raw

PATCH v2 5/5 media: i2c: saa7115: Add missing media_entity_cleanup()

In reply to Biren Pandya

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

---
 drivers/media/i2c/saa7115.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/i2c/saa7115.c +2 -0
index 48d6730d9271..64adfff3001b 100644
@@ -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[] = {
Signature · 1 line
2.50.1 (Apple Git-155)