diff mbox

drm/locking: Allow NULL crtc in drm_modeset_legacy_acquire_ctx

Message ID 1416584418-17994-1-git-send-email-daniel.vetter@ffwll.ch (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Vetter Nov. 21, 2014, 3:40 p.m. UTC
I've missed checking this and so didn't notice that there's a NULL
check missing. Since depending upon calling context the crtc might not
even be there (disable-me-harder does happen around planes, especially
in cleanup code) we need to dodge the oops and look at the global
acquire ctx.

Reported-by: "Jasper St. Pierre" <jstpierre@mecheye.net>
Cc: "Jasper St. Pierre" <jstpierre@mecheye.net>
Cc: Rob Clark <robdclark@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_modeset_lock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ville Syrjälä Nov. 21, 2014, 4:21 p.m. UTC | #1
On Fri, Nov 21, 2014 at 04:40:18PM +0100, Daniel Vetter wrote:
> I've missed checking this and so didn't notice that there's a NULL
> check missing. Since depending upon calling context the crtc might not
> even be there (disable-me-harder does happen around planes, especially
> in cleanup code) we need to dodge the oops and look at the global
> acquire ctx.
> 
> Reported-by: "Jasper St. Pierre" <jstpierre@mecheye.net>
> Cc: "Jasper St. Pierre" <jstpierre@mecheye.net>
> Cc: Rob Clark <robdclark@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/drm_modeset_lock.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_modeset_lock.c b/drivers/gpu/drm/drm_modeset_lock.c
> index 474e4d12a2d8..93d28269e3bd 100644
> --- a/drivers/gpu/drm/drm_modeset_lock.c
> +++ b/drivers/gpu/drm/drm_modeset_lock.c
> @@ -209,7 +209,7 @@ EXPORT_SYMBOL(drm_modeset_lock_crtc);
>  struct drm_modeset_acquire_ctx *
>  drm_modeset_legacy_acquire_ctx(struct drm_crtc *crtc)
>  {
> -	if (crtc->acquire_ctx)
> +	if (crtc && crtc->acquire_ctx)
>  		return crtc->acquire_ctx;
>  
>  	WARN_ON(!crtc->dev->mode_config.acquire_ctx);
  	         ^^^^^^

How's that going to work without the crtc?

> -- 
> 2.1.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_modeset_lock.c b/drivers/gpu/drm/drm_modeset_lock.c
index 474e4d12a2d8..93d28269e3bd 100644
--- a/drivers/gpu/drm/drm_modeset_lock.c
+++ b/drivers/gpu/drm/drm_modeset_lock.c
@@ -209,7 +209,7 @@  EXPORT_SYMBOL(drm_modeset_lock_crtc);
 struct drm_modeset_acquire_ctx *
 drm_modeset_legacy_acquire_ctx(struct drm_crtc *crtc)
 {
-	if (crtc->acquire_ctx)
+	if (crtc && crtc->acquire_ctx)
 		return crtc->acquire_ctx;
 
 	WARN_ON(!crtc->dev->mode_config.acquire_ctx);