diff mbox series

media: cedrus: Fix initialization order

Message ID 20190407184728.16620-1-jernej.skrabec@siol.net (mailing list archive)
State New, archived
Headers show
Series media: cedrus: Fix initialization order | expand

Commit Message

Jernej Škrabec April 7, 2019, 6:47 p.m. UTC
Currently, MEDIA_IOC_G_TOPOLOGY ioctl on cedrus fails due to incorrect
initialization order. Fix that by moving video_register_device() before
v4l2_m2m_register_media_controller() and while at it, fix error path.

Reported-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 drivers/staging/media/sunxi/cedrus/cedrus.c | 24 ++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)

Comments

Paul Kocialkowski April 8, 2019, 8:18 a.m. UTC | #1
Hi,

Le dimanche 07 avril 2019 à 20:47 +0200, Jernej Skrabec a écrit :
> Currently, MEDIA_IOC_G_TOPOLOGY ioctl on cedrus fails due to incorrect
> initialization order. Fix that by moving video_register_device() before
> v4l2_m2m_register_media_controller() and while at it, fix error path.
> 
> Reported-by: Jonas Karlman <jonas@kwiboo.se>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>

Thanks for the fix, good catch!

Acked-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>

Cheers,

Paul

> ---
>  drivers/staging/media/sunxi/cedrus/cedrus.c | 24 ++++++++++-----------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c
> index b98add3cdedd..d0429c0e6b6b 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus.c
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
> @@ -300,7 +300,7 @@ static int cedrus_probe(struct platform_device *pdev)
>  			 "Failed to initialize V4L2 M2M device\n");
>  		ret = PTR_ERR(dev->m2m_dev);
>  
> -		goto err_video;
> +		goto err_v4l2;
>  	}
>  
>  	dev->mdev.dev = &pdev->dev;
> @@ -310,23 +310,23 @@ static int cedrus_probe(struct platform_device *pdev)
>  	dev->mdev.ops = &cedrus_m2m_media_ops;
>  	dev->v4l2_dev.mdev = &dev->mdev;
>  
> -	ret = v4l2_m2m_register_media_controller(dev->m2m_dev, vfd,
> -						 MEDIA_ENT_F_PROC_VIDEO_DECODER);
> -	if (ret) {
> -		v4l2_err(&dev->v4l2_dev,
> -			 "Failed to initialize V4L2 M2M media controller\n");
> -		goto err_m2m;
> -	}
> -
>  	ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
>  	if (ret) {
>  		v4l2_err(&dev->v4l2_dev, "Failed to register video device\n");
> -		goto err_v4l2;
> +		goto err_m2m;
>  	}
>  
>  	v4l2_info(&dev->v4l2_dev,
>  		  "Device registered as /dev/video%d\n", vfd->num);
>  
> +	ret = v4l2_m2m_register_media_controller(dev->m2m_dev, vfd,
> +						 MEDIA_ENT_F_PROC_VIDEO_DECODER);
> +	if (ret) {
> +		v4l2_err(&dev->v4l2_dev,
> +			 "Failed to initialize V4L2 M2M media controller\n");
> +		goto err_video;
> +	}
> +
>  	ret = media_device_register(&dev->mdev);
>  	if (ret) {
>  		v4l2_err(&dev->v4l2_dev, "Failed to register media device\n");
> @@ -339,10 +339,10 @@ static int cedrus_probe(struct platform_device *pdev)
>  
>  err_m2m_mc:
>  	v4l2_m2m_unregister_media_controller(dev->m2m_dev);
> -err_m2m:
> -	v4l2_m2m_release(dev->m2m_dev);
>  err_video:
>  	video_unregister_device(&dev->vfd);
> +err_m2m:
> +	v4l2_m2m_release(dev->m2m_dev);
>  err_v4l2:
>  	v4l2_device_unregister(&dev->v4l2_dev);
>
Paul Kocialkowski April 19, 2019, 10:06 a.m. UTC | #2
Hi,

On Mon, 2019-04-08 at 10:18 +0200, Paul Kocialkowski wrote:
> Hi,
> 
> Le dimanche 07 avril 2019 à 20:47 +0200, Jernej Skrabec a écrit :
> > Currently, MEDIA_IOC_G_TOPOLOGY ioctl on cedrus fails due to incorrect
> > initialization order. Fix that by moving video_register_device() before
> > v4l2_m2m_register_media_controller() and while at it, fix error path.
> > 
> > Reported-by: Jonas Karlman <jonas@kwiboo.se>
> > Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
> 
> Thanks for the fix, good catch!
> 
> Acked-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>

Looks like this patch wasn't picked-up yet. Could we take it in?
I think it would also deserve a:

Fixes: 50e761516f2b ("media: platform: Add Cedrus VPU decoder driver")

Cheers,

Paul

> > ---
> >  drivers/staging/media/sunxi/cedrus/cedrus.c | 24 ++++++++++-----------
> >  1 file changed, 12 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c
> > index b98add3cdedd..d0429c0e6b6b 100644
> > --- a/drivers/staging/media/sunxi/cedrus/cedrus.c
> > +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
> > @@ -300,7 +300,7 @@ static int cedrus_probe(struct platform_device *pdev)
> >  			 "Failed to initialize V4L2 M2M device\n");
> >  		ret = PTR_ERR(dev->m2m_dev);
> >  
> > -		goto err_video;
> > +		goto err_v4l2;
> >  	}
> >  
> >  	dev->mdev.dev = &pdev->dev;
> > @@ -310,23 +310,23 @@ static int cedrus_probe(struct platform_device *pdev)
> >  	dev->mdev.ops = &cedrus_m2m_media_ops;
> >  	dev->v4l2_dev.mdev = &dev->mdev;
> >  
> > -	ret = v4l2_m2m_register_media_controller(dev->m2m_dev, vfd,
> > -						 MEDIA_ENT_F_PROC_VIDEO_DECODER);
> > -	if (ret) {
> > -		v4l2_err(&dev->v4l2_dev,
> > -			 "Failed to initialize V4L2 M2M media controller\n");
> > -		goto err_m2m;
> > -	}
> > -
> >  	ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
> >  	if (ret) {
> >  		v4l2_err(&dev->v4l2_dev, "Failed to register video device\n");
> > -		goto err_v4l2;
> > +		goto err_m2m;
> >  	}
> >  
> >  	v4l2_info(&dev->v4l2_dev,
> >  		  "Device registered as /dev/video%d\n", vfd->num);
> >  
> > +	ret = v4l2_m2m_register_media_controller(dev->m2m_dev, vfd,
> > +						 MEDIA_ENT_F_PROC_VIDEO_DECODER);
> > +	if (ret) {
> > +		v4l2_err(&dev->v4l2_dev,
> > +			 "Failed to initialize V4L2 M2M media controller\n");
> > +		goto err_video;
> > +	}
> > +
> >  	ret = media_device_register(&dev->mdev);
> >  	if (ret) {
> >  		v4l2_err(&dev->v4l2_dev, "Failed to register media device\n");
> > @@ -339,10 +339,10 @@ static int cedrus_probe(struct platform_device *pdev)
> >  
> >  err_m2m_mc:
> >  	v4l2_m2m_unregister_media_controller(dev->m2m_dev);
> > -err_m2m:
> > -	v4l2_m2m_release(dev->m2m_dev);
> >  err_video:
> >  	video_unregister_device(&dev->vfd);
> > +err_m2m:
> > +	v4l2_m2m_release(dev->m2m_dev);
> >  err_v4l2:
> >  	v4l2_device_unregister(&dev->v4l2_dev);
> >
diff mbox series

Patch

diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c
index b98add3cdedd..d0429c0e6b6b 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
@@ -300,7 +300,7 @@  static int cedrus_probe(struct platform_device *pdev)
 			 "Failed to initialize V4L2 M2M device\n");
 		ret = PTR_ERR(dev->m2m_dev);
 
-		goto err_video;
+		goto err_v4l2;
 	}
 
 	dev->mdev.dev = &pdev->dev;
@@ -310,23 +310,23 @@  static int cedrus_probe(struct platform_device *pdev)
 	dev->mdev.ops = &cedrus_m2m_media_ops;
 	dev->v4l2_dev.mdev = &dev->mdev;
 
-	ret = v4l2_m2m_register_media_controller(dev->m2m_dev, vfd,
-						 MEDIA_ENT_F_PROC_VIDEO_DECODER);
-	if (ret) {
-		v4l2_err(&dev->v4l2_dev,
-			 "Failed to initialize V4L2 M2M media controller\n");
-		goto err_m2m;
-	}
-
 	ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
 	if (ret) {
 		v4l2_err(&dev->v4l2_dev, "Failed to register video device\n");
-		goto err_v4l2;
+		goto err_m2m;
 	}
 
 	v4l2_info(&dev->v4l2_dev,
 		  "Device registered as /dev/video%d\n", vfd->num);
 
+	ret = v4l2_m2m_register_media_controller(dev->m2m_dev, vfd,
+						 MEDIA_ENT_F_PROC_VIDEO_DECODER);
+	if (ret) {
+		v4l2_err(&dev->v4l2_dev,
+			 "Failed to initialize V4L2 M2M media controller\n");
+		goto err_video;
+	}
+
 	ret = media_device_register(&dev->mdev);
 	if (ret) {
 		v4l2_err(&dev->v4l2_dev, "Failed to register media device\n");
@@ -339,10 +339,10 @@  static int cedrus_probe(struct platform_device *pdev)
 
 err_m2m_mc:
 	v4l2_m2m_unregister_media_controller(dev->m2m_dev);
-err_m2m:
-	v4l2_m2m_release(dev->m2m_dev);
 err_video:
 	video_unregister_device(&dev->vfd);
+err_m2m:
+	v4l2_m2m_release(dev->m2m_dev);
 err_v4l2:
 	v4l2_device_unregister(&dev->v4l2_dev);