Re: [PATCH v3 2/4] media: renesas: csisp: 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 <ak5vspKMxPLZ6Zsi@zed>
Hi Biren

On Sat, Jul 04, 2026 at 11:16:41PM +0530, Biren Pandya wrote:
> The probe error path and the remove function fail to call
> media_entity_cleanup() upon teardown.
>
> While currently a no-op in most cases, 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. Furthermore, introduce a
> dedicated error_entity label in the probe error path to ensure the cleanup
> is only invoked if media_entity_pads_init() has successfully completed.

Empty line please

It could be added when applying though


> Signed-off-by: Biren Pandya <[email protected]>
> ---
>  drivers/media/platform/renesas/rcar-isp/csisp.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/renesas/rcar-isp/csisp.c b/drivers/media/platform/renesas/rcar-isp/csisp.c
> index 8fb2cc3b5650..61558a71ee35 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,8 @@ 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 +571,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);

Reviewed-by: Jacopo Mondi <[email protected]>

Thanks
  j
>
>  	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.