Re: [PATCH v3 1/4] media: renesas: rcar-csi2: Add missing media_entity_cleanup()

Jacopo Mondi <[email protected]>
Newsgroups org.kernel.vger.linux-renesas-soc,org.kernel.vger.linux-kernel,org.kernel.vger.linux-media
Message-ID <ak5yyRucx7IKvcse@zed>
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 <[email protected]>
> ---
>  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 <[email protected]>


>
>  	pm_runtime_disable(&pdev->dev);
>  }
> --
> 2.50.1 (Apple Git-155)
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.