* [PATCH v6 1/4] media: renesas: rcar-csi2: Add missing media_entity_cleanup()
[not found] <20260709091813.67081-6-birenpandya@gmail.com>
@ 2026-07-09 9:18 ` Biren Pandya
2026-07-09 9:18 ` [PATCH v6 2/4] media: renesas: csisp: " Biren Pandya
` (2 subsequent siblings)
3 siblings, 0 replies; 4+ messages in thread
From: Biren Pandya @ 2026-07-09 9:18 UTC (permalink / raw)
To: niklas.soderlund, mchehab, geert+renesas, magnus.damm,
linux-media, linux-renesas-soc, linux-kernel
Cc: jacopo.mondi+renesas, Biren Pandya
The probe error paths and the remove function fail to call
media_entity_cleanup() upon teardown.
While currently a no-op, calling media_entity_cleanup()
is an API requirement for entities initialized with
media_entity_pads_init() to prevent memory leaks.
Add the missing media_entity_cleanup() calls.
Signed-off-by: Biren Pandya <birenpandya@gmail.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
---
drivers/media/platform/renesas/rcar-csi2.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c
index 7305cc4a04cb1..f9c818b0faf7e 100644
--- a/drivers/media/platform/renesas/rcar-csi2.c
+++ b/drivers/media/platform/renesas/rcar-csi2.c
@@ -2631,6 +2631,7 @@ static int rcsi2_probe(struct platform_device *pdev)
v4l2_subdev_cleanup(&priv->subdev);
error_pm_runtime:
pm_runtime_disable(&pdev->dev);
+ media_entity_cleanup(&priv->subdev.entity);
error_async:
v4l2_async_nf_unregister(&priv->notifier);
v4l2_async_nf_cleanup(&priv->notifier);
@@ -2646,6 +2647,7 @@ static void rcsi2_remove(struct platform_device *pdev)
v4l2_async_nf_cleanup(&priv->notifier);
v4l2_async_unregister_subdev(&priv->subdev);
v4l2_subdev_cleanup(&priv->subdev);
+ media_entity_cleanup(&priv->subdev.entity);
pm_runtime_disable(&pdev->dev);
}
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v6 2/4] media: renesas: csisp: Add missing media_entity_cleanup()
[not found] <20260709091813.67081-6-birenpandya@gmail.com>
2026-07-09 9:18 ` [PATCH v6 1/4] media: renesas: rcar-csi2: Add missing media_entity_cleanup() Biren Pandya
@ 2026-07-09 9:18 ` Biren Pandya
2026-07-09 9:18 ` [PATCH v6 3/4] media: renesas: rcar-core: " Biren Pandya
2026-07-09 9:18 ` [PATCH v6 4/4] media: renesas: rzg2l-core: " Biren Pandya
3 siblings, 0 replies; 4+ messages in thread
From: Biren Pandya @ 2026-07-09 9:18 UTC (permalink / raw)
To: niklas.soderlund, mchehab, geert+renesas, magnus.damm,
linux-media, linux-renesas-soc, linux-kernel
Cc: jacopo.mondi+renesas, Biren Pandya
The probe error path and remove function fail to call
media_entity_cleanup() upon teardown.
While currently a no-op, calling media_entity_cleanup()
is an API requirement for entities initialized with
media_entity_pads_init() to prevent memory leaks.
Add a dedicated error_entity label so the cleanup is only invoked when
media_entity_pads_init() has actually succeeded. This ensures that the
teardown logic properly mirrors initialization.
Signed-off-by: Biren Pandya <birenpandya@gmail.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
---
drivers/media/platform/renesas/rcar-isp/csisp.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/renesas/rcar-isp/csisp.c b/drivers/media/platform/renesas/rcar-isp/csisp.c
index 8fb2cc3b56503..199b70ea841d9 100644
--- a/drivers/media/platform/renesas/rcar-isp/csisp.c
+++ b/drivers/media/platform/renesas/rcar-isp/csisp.c
@@ -539,7 +539,7 @@ static int risp_probe(struct platform_device *pdev)
ret = v4l2_subdev_init_finalize(&isp->subdev);
if (ret)
- goto error_notifier;
+ goto error_entity;
ret = v4l2_async_register_subdev(&isp->subdev);
if (ret < 0)
@@ -551,6 +551,9 @@ static int risp_probe(struct platform_device *pdev)
error_subdev:
v4l2_subdev_cleanup(&isp->subdev);
+error_entity:
+ media_entity_cleanup(&isp->subdev.entity);
+
error_notifier:
v4l2_async_nf_unregister(&isp->notifier);
v4l2_async_nf_cleanup(&isp->notifier);
@@ -569,6 +572,7 @@ static void risp_remove(struct platform_device *pdev)
v4l2_async_unregister_subdev(&isp->subdev);
v4l2_subdev_cleanup(&isp->subdev);
+ media_entity_cleanup(&isp->subdev.entity);
pm_runtime_disable(&pdev->dev);
}
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v6 3/4] media: renesas: rcar-core: Add missing media_entity_cleanup()
[not found] <20260709091813.67081-6-birenpandya@gmail.com>
2026-07-09 9:18 ` [PATCH v6 1/4] media: renesas: rcar-csi2: Add missing media_entity_cleanup() Biren Pandya
2026-07-09 9:18 ` [PATCH v6 2/4] media: renesas: csisp: " Biren Pandya
@ 2026-07-09 9:18 ` Biren Pandya
2026-07-09 9:18 ` [PATCH v6 4/4] media: renesas: rzg2l-core: " Biren Pandya
3 siblings, 0 replies; 4+ messages in thread
From: Biren Pandya @ 2026-07-09 9:18 UTC (permalink / raw)
To: niklas.soderlund, mchehab, geert+renesas, magnus.damm,
linux-media, linux-renesas-soc, linux-kernel
Cc: jacopo.mondi+renesas, Biren Pandya
The probe error path and remove function fail to call
media_entity_cleanup() upon teardown.
While currently a no-op, calling media_entity_cleanup()
is an API requirement for entities initialized with
media_entity_pads_init() to prevent memory leaks.
Add a dedicated error_entity label so the cleanup is only invoked when
media_entity_pads_init() has actually succeeded. This ensures that the
teardown logic properly mirrors initialization.
Signed-off-by: Biren Pandya <birenpandya@gmail.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
---
drivers/media/platform/renesas/rcar-vin/rcar-core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-core.c b/drivers/media/platform/renesas/rcar-vin/rcar-core.c
index c8d564aa1eba8..5bae8eb0ee19b 100644
--- a/drivers/media/platform/renesas/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/renesas/rcar-vin/rcar-core.c
@@ -1211,7 +1211,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
ret = rvin_create_controls(vin);
if (ret < 0)
- goto err_id;
+ goto err_entity;
switch (vin->info->model) {
case RCAR_GEN3:
@@ -1246,6 +1246,8 @@ static int rcar_vin_probe(struct platform_device *pdev)
err_ctrl:
rvin_free_controls(vin);
+err_entity:
+ media_entity_cleanup(&vin->vdev.entity);
err_id:
rvin_id_put(vin);
err_dma:
@@ -1270,6 +1272,7 @@ static void rcar_vin_remove(struct platform_device *pdev)
rvin_group_put(vin);
rvin_free_controls(vin);
+ media_entity_cleanup(&vin->vdev.entity);
rvin_id_put(vin);
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v6 4/4] media: renesas: rzg2l-core: Add missing media_entity_cleanup()
[not found] <20260709091813.67081-6-birenpandya@gmail.com>
` (2 preceding siblings ...)
2026-07-09 9:18 ` [PATCH v6 3/4] media: renesas: rcar-core: " Biren Pandya
@ 2026-07-09 9:18 ` Biren Pandya
3 siblings, 0 replies; 4+ messages in thread
From: Biren Pandya @ 2026-07-09 9:18 UTC (permalink / raw)
To: mchehab, linux-media, linux-kernel; +Cc: jacopo.mondi+renesas, Biren Pandya
The media initialization error path and the remove function fail to call
media_entity_cleanup() upon teardown.
While currently a no-op, calling media_entity_cleanup()
is an API requirement for entities initialized with
media_entity_pads_init() to prevent memory leaks.
Add the missing media_entity_cleanup() calls.
Additionally, rework the error path in rzg2l_cru_media_init() to use
an error_mc_parse label, ensuring that cleanup functions are invoked
and the unnecessary mutex lock is removed.
Signed-off-by: Biren Pandya <birenpandya@gmail.com>
---
.../media/platform/renesas/rzg2l-cru/rzg2l-core.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c
index 3c5fbd857371c..ee555b01c3aa1 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c
@@ -230,13 +230,17 @@ static int rzg2l_cru_media_init(struct rzg2l_cru_dev *cru)
media_device_init(mdev);
ret = rzg2l_cru_mc_parse_of_graph(cru);
- if (ret) {
- mutex_lock(&cru->mdev_lock);
- cru->v4l2_dev.mdev = NULL;
- mutex_unlock(&cru->mdev_lock);
- }
+ if (ret)
+ goto error_mc_parse;
return 0;
+
+error_mc_parse:
+ media_device_cleanup(mdev);
+ cru->v4l2_dev.mdev = NULL;
+ media_entity_cleanup(&cru->vdev.entity);
+ mutex_destroy(&cru->mdev_lock);
+ return ret;
}
static int rzg2l_cru_probe(struct platform_device *pdev)
@@ -312,6 +316,7 @@ static void rzg2l_cru_remove(struct platform_device *pdev)
v4l2_async_nf_cleanup(&cru->notifier);
rzg2l_cru_video_unregister(cru);
+ media_entity_cleanup(&cru->vdev.entity);
media_device_cleanup(&cru->mdev);
mutex_destroy(&cru->mdev_lock);
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-09 9:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260709091813.67081-6-birenpandya@gmail.com>
2026-07-09 9:18 ` [PATCH v6 1/4] media: renesas: rcar-csi2: Add missing media_entity_cleanup() Biren Pandya
2026-07-09 9:18 ` [PATCH v6 2/4] media: renesas: csisp: " Biren Pandya
2026-07-09 9:18 ` [PATCH v6 3/4] media: renesas: rcar-core: " Biren Pandya
2026-07-09 9:18 ` [PATCH v6 4/4] media: renesas: rzg2l-core: " Biren Pandya
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox