linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/fb-helper: Add missed unlocks in setcmap_legacy()
@ 2020-12-03 14:42 Chuhong Yuan
  2020-12-03 16:11 ` Peter Rosin
  0 siblings, 1 reply; 3+ messages in thread
From: Chuhong Yuan @ 2020-12-03 14:42 UTC (permalink / raw)
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Peter Rosin, dri-devel,
	linux-kernel, Chuhong Yuan

setcmap_legacy() does not call drm_modeset_unlock_all() in some exits,
add the missed unlocks with goto to fix it.

Fixes: 964c60063bff ("drm/fb-helper: separate the fb_setcmap helper into atomic and legacy paths")
Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---
 drivers/gpu/drm/drm_fb_helper.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 1543d9d10970..8033467db4be 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -923,11 +923,15 @@ static int setcmap_legacy(struct fb_cmap *cmap, struct fb_info *info)
 	drm_modeset_lock_all(fb_helper->dev);
 	drm_client_for_each_modeset(modeset, &fb_helper->client) {
 		crtc = modeset->crtc;
-		if (!crtc->funcs->gamma_set || !crtc->gamma_size)
-			return -EINVAL;
+		if (!crtc->funcs->gamma_set || !crtc->gamma_size) {
+			ret = -EINVAL;
+			goto out;
+		}
 
-		if (cmap->start + cmap->len > crtc->gamma_size)
-			return -EINVAL;
+		if (cmap->start + cmap->len > crtc->gamma_size) {
+			ret = -EINVAL;
+			goto out;
+		}
 
 		r = crtc->gamma_store;
 		g = r + crtc->gamma_size;
@@ -940,8 +944,9 @@ static int setcmap_legacy(struct fb_cmap *cmap, struct fb_info *info)
 		ret = crtc->funcs->gamma_set(crtc, r, g, b,
 					     crtc->gamma_size, NULL);
 		if (ret)
-			return ret;
+			goto out;
 	}
+out:
 	drm_modeset_unlock_all(fb_helper->dev);
 
 	return ret;
-- 
2.26.2


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

* Re: [PATCH] drm/fb-helper: Add missed unlocks in setcmap_legacy()
  2020-12-03 14:42 [PATCH] drm/fb-helper: Add missed unlocks in setcmap_legacy() Chuhong Yuan
@ 2020-12-03 16:11 ` Peter Rosin
  2020-12-03 16:39   ` Daniel Vetter
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Rosin @ 2020-12-03 16:11 UTC (permalink / raw)
  To: Chuhong Yuan
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, dri-devel, linux-kernel

Hi!

On 2020-12-03 15:42, Chuhong Yuan wrote:
> setcmap_legacy() does not call drm_modeset_unlock_all() in some exits,
> add the missed unlocks with goto to fix it.
> 
> Fixes: 964c60063bff ("drm/fb-helper: separate the fb_setcmap helper into atomic and legacy paths")
> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>

Yup, my patch fumbled the locking. Sorry, and thanks for cleaning up my mess!

Acked-by: Peter Rosin <peda@axentia.se>

(Spelled that as Ached-by at first, what does that mean??)

Cheers,
Peter

> ---
>  drivers/gpu/drm/drm_fb_helper.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 1543d9d10970..8033467db4be 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -923,11 +923,15 @@ static int setcmap_legacy(struct fb_cmap *cmap, struct fb_info *info)
>  	drm_modeset_lock_all(fb_helper->dev);
>  	drm_client_for_each_modeset(modeset, &fb_helper->client) {
>  		crtc = modeset->crtc;
> -		if (!crtc->funcs->gamma_set || !crtc->gamma_size)
> -			return -EINVAL;
> +		if (!crtc->funcs->gamma_set || !crtc->gamma_size) {
> +			ret = -EINVAL;
> +			goto out;
> +		}
>  
> -		if (cmap->start + cmap->len > crtc->gamma_size)
> -			return -EINVAL;
> +		if (cmap->start + cmap->len > crtc->gamma_size) {
> +			ret = -EINVAL;
> +			goto out;
> +		}
>  
>  		r = crtc->gamma_store;
>  		g = r + crtc->gamma_size;
> @@ -940,8 +944,9 @@ static int setcmap_legacy(struct fb_cmap *cmap, struct fb_info *info)
>  		ret = crtc->funcs->gamma_set(crtc, r, g, b,
>  					     crtc->gamma_size, NULL);
>  		if (ret)
> -			return ret;
> +			goto out;
>  	}
> +out:
>  	drm_modeset_unlock_all(fb_helper->dev);
>  
>  	return ret;
> 

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

* Re: [PATCH] drm/fb-helper: Add missed unlocks in setcmap_legacy()
  2020-12-03 16:11 ` Peter Rosin
@ 2020-12-03 16:39   ` Daniel Vetter
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Vetter @ 2020-12-03 16:39 UTC (permalink / raw)
  To: Peter Rosin
  Cc: Chuhong Yuan, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, dri-devel,
	Linux Kernel Mailing List

On Thu, Dec 3, 2020 at 5:11 PM Peter Rosin <peda@axentia.se> wrote:
>
> Hi!
>
> On 2020-12-03 15:42, Chuhong Yuan wrote:
> > setcmap_legacy() does not call drm_modeset_unlock_all() in some exits,
> > add the missed unlocks with goto to fix it.
> >
> > Fixes: 964c60063bff ("drm/fb-helper: separate the fb_setcmap helper into atomic and legacy paths")
> > Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
>
> Yup, my patch fumbled the locking. Sorry, and thanks for cleaning up my mess!
>
> Acked-by: Peter Rosin <peda@axentia.se>
>
> (Spelled that as Ached-by at first, what does that mean??)

Merged already before I've seen your ack here (and we don't rebase so
can't add it now), thanks for the patch and all.
-Daniel

>
> Cheers,
> Peter
>
> > ---
> >  drivers/gpu/drm/drm_fb_helper.c | 15 ++++++++++-----
> >  1 file changed, 10 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> > index 1543d9d10970..8033467db4be 100644
> > --- a/drivers/gpu/drm/drm_fb_helper.c
> > +++ b/drivers/gpu/drm/drm_fb_helper.c
> > @@ -923,11 +923,15 @@ static int setcmap_legacy(struct fb_cmap *cmap, struct fb_info *info)
> >       drm_modeset_lock_all(fb_helper->dev);
> >       drm_client_for_each_modeset(modeset, &fb_helper->client) {
> >               crtc = modeset->crtc;
> > -             if (!crtc->funcs->gamma_set || !crtc->gamma_size)
> > -                     return -EINVAL;
> > +             if (!crtc->funcs->gamma_set || !crtc->gamma_size) {
> > +                     ret = -EINVAL;
> > +                     goto out;
> > +             }
> >
> > -             if (cmap->start + cmap->len > crtc->gamma_size)
> > -                     return -EINVAL;
> > +             if (cmap->start + cmap->len > crtc->gamma_size) {
> > +                     ret = -EINVAL;
> > +                     goto out;
> > +             }
> >
> >               r = crtc->gamma_store;
> >               g = r + crtc->gamma_size;
> > @@ -940,8 +944,9 @@ static int setcmap_legacy(struct fb_cmap *cmap, struct fb_info *info)
> >               ret = crtc->funcs->gamma_set(crtc, r, g, b,
> >                                            crtc->gamma_size, NULL);
> >               if (ret)
> > -                     return ret;
> > +                     goto out;
> >       }
> > +out:
> >       drm_modeset_unlock_all(fb_helper->dev);
> >
> >       return ret;
> >



-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

end of thread, other threads:[~2020-12-03 16:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 14:42 [PATCH] drm/fb-helper: Add missed unlocks in setcmap_legacy() Chuhong Yuan
2020-12-03 16:11 ` Peter Rosin
2020-12-03 16:39   ` Daniel Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).