Re: [PATCH v3 1/4] media: renesas: rcar-csi2: Add missing media_entity_cleanup()
From: Jacopo Mondi
Date: Wed Jul 08 2026 - 11:59:00 EST
Hi Biren
On Sat, Jul 04, 2026 at 11:16:40PM +0530, Biren Pandya wrote:
> The probe error paths and the remove function fail to call
> media_entity_cleanup() upon teardown.
>
> While currently a no-op in most cases, calling media_entity_cleanup()
Here and in the other patches s/in most cases//
> is an API requirement for entities initialized with media_entity_pads_init()
> to prevent memory leaks.
>
> Add the missing media_entity_cleanup() calls.
Missing empty line
> Signed-off-by: Biren Pandya <birenpandya@xxxxxxxxx>
> ---
> 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 7305cc4a04cb..f9c818b0faf7 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);
It's hard to guess right now as media_entity_cleanup() is a nop,
but it would feel more safe to first cleanup subdev.entity and then
subdev itself
media_entity_cleanup(&priv->subdev.entity);
v4l2_subdev_cleanup(&priv->subdev);
However, the probe() error path already does it in reverse, order,
so...
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@xxxxxxxxxxxxxxxx>
>
> pm_runtime_disable(&pdev->dev);
> }
> --
> 2.50.1 (Apple Git-155)
>
>