public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] media: cedrus: clean up media device on probe failure
@ 2026-04-30 14:25 박명훈
  2026-05-05 13:09 ` Paul Kocialkowski
  0 siblings, 1 reply; 2+ messages in thread
From: 박명훈 @ 2026-04-30 14:25 UTC (permalink / raw)
  To: Maxime Ripard, Paul Kocialkowski, Mauro Carvalho Chehab,
	Greg Kroah-Hartman, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
  Cc: Myeonghun Pak, linux-media, linux-staging, linux-arm-kernel,
	linux-sunxi, linux-kernel, stable, Ijae Kim

From: Myeonghun Pak <mhun512@gmail.com>

cedrus_probe() initializes the media device before registering the video
device, the media controller, and the media device. If any of those later
steps fails, probe returns without calling media_device_cleanup(), so the
media device internals initialized by media_device_init() are left behind.

Add a media-device cleanup label to the probe unwind path and route video
registration failures through it as well.

Fixes: 50e761516f2b8c ("media: platform: Add Cedrus VPU decoder driver")
Cc: stable@vger.kernel.org
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
Changes in v2:
- Drop the now-unused err_m2m label.

 drivers/staging/media/sunxi/cedrus/cedrus.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c
index 6600245dff..2c25654640 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
@@ -507,7 +507,7 @@ static int cedrus_probe(struct platform_device *pdev)
 	ret = video_register_device(vfd, VFL_TYPE_VIDEO, 0);
 	if (ret) {
 		v4l2_err(&dev->v4l2_dev, "Failed to register video device\n");
-		goto err_m2m;
+		goto err_media_cleanup;
 	}
 
 	v4l2_info(&dev->v4l2_dev,
@@ -533,6 +533,7 @@ static int cedrus_probe(struct platform_device *pdev)
 	v4l2_m2m_unregister_media_controller(dev->m2m_dev);
 err_video:
 	video_unregister_device(&dev->vfd);
-err_m2m:
+err_media_cleanup:
+	media_device_cleanup(&dev->mdev);
 	v4l2_m2m_release(dev->m2m_dev);
 err_v4l2:
-- 
2.50.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] media: cedrus: clean up media device on probe failure
  2026-04-30 14:25 [PATCH v2] media: cedrus: clean up media device on probe failure 박명훈
@ 2026-05-05 13:09 ` Paul Kocialkowski
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Kocialkowski @ 2026-05-05 13:09 UTC (permalink / raw)
  To: 박명훈
  Cc: Maxime Ripard, Mauro Carvalho Chehab, Greg Kroah-Hartman,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, linux-media,
	linux-staging, linux-arm-kernel, linux-sunxi, linux-kernel,
	stable, Ijae Kim

[-- Attachment #1: Type: text/plain, Size: 2300 bytes --]

Hi,

On Thu 30 Apr 26, 23:25, 박명훈 wrote:
> From: Myeonghun Pak <mhun512@gmail.com>
> 
> cedrus_probe() initializes the media device before registering the video
> device, the media controller, and the media device. If any of those later
> steps fails, probe returns without calling media_device_cleanup(), so the
> media device internals initialized by media_device_init() are left behind.
> 
> Add a media-device cleanup label to the probe unwind path and route video
> registration failures through it as well.

The label should be named "err_media" instead of "err_media_cleanup" to be
consistent with the other labels. With that fixed:

Reviewed-by: Paul Kocialkowski <paulk@sys-base.io>

Thanks for the fix!

Paul

> Fixes: 50e761516f2b8c ("media: platform: Add Cedrus VPU decoder driver")
> Cc: stable@vger.kernel.org
> Co-developed-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
> ---
> Changes in v2:
> - Drop the now-unused err_m2m label.
> 
>  drivers/staging/media/sunxi/cedrus/cedrus.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c
> index 6600245dff..2c25654640 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus.c
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
> @@ -507,7 +507,7 @@ static int cedrus_probe(struct platform_device *pdev)
>  	ret = video_register_device(vfd, VFL_TYPE_VIDEO, 0);
>  	if (ret) {
>  		v4l2_err(&dev->v4l2_dev, "Failed to register video device\n");
> -		goto err_m2m;
> +		goto err_media_cleanup;
>  	}
>  
>  	v4l2_info(&dev->v4l2_dev,
> @@ -533,6 +533,7 @@ static int cedrus_probe(struct platform_device *pdev)
>  	v4l2_m2m_unregister_media_controller(dev->m2m_dev);
>  err_video:
>  	video_unregister_device(&dev->vfd);
> -err_m2m:
> +err_media_cleanup:
> +	media_device_cleanup(&dev->mdev);
>  	v4l2_m2m_release(dev->m2m_dev);
>  err_v4l2:
> -- 
> 2.50.1

-- 
Paul Kocialkowski,

Independent contractor - sys-base - https://www.sys-base.io/
Free software developer - https://www.paulk.fr/

Expert in multimedia, graphics and embedded hardware support with Linux.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-05 13:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-30 14:25 [PATCH v2] media: cedrus: clean up media device on probe failure 박명훈
2026-05-05 13:09 ` Paul Kocialkowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox