drm/i915: Do not dereference NULL crtc or fb until after checking
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 2 Aug 2013 19:39:49 +0000 (20:39 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Sun, 4 Aug 2013 19:13:43 +0000 (21:13 +0200)
Fixes regression from
commit 4906557eb37b7fef84fad4304acef6dedf919880
Author: Rodrigo Vivi <rodrigo.vivi@gmail.com>
Date:   Thu Jul 11 18:45:05 2013 -0300

    drm/i915: Hook PSR functionality

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67526
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Rodrigo Vivi <rodrigo.vivi@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_dp.c

index 4a7ba5ea9ee353e8d8df6455ef06f309d5d40914..d0c3f9b08387b24a003eba3409eac1c8f6d575f0 100644 (file)
@@ -1545,12 +1545,21 @@ static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp)
                return false;
        }
 
+       crtc = dig_port->base.base.crtc;
+       if (crtc == NULL) {
+               DRM_DEBUG_KMS("crtc not active for PSR\n");
+               dev_priv->no_psr_reason = PSR_CRTC_NOT_ACTIVE;
+               return false;
+       }
+
+       intel_crtc = to_intel_crtc(crtc);
        if (!intel_crtc->active || !crtc->fb || !crtc->mode.clock) {
                DRM_DEBUG_KMS("crtc not active for PSR\n");
                dev_priv->no_psr_reason = PSR_CRTC_NOT_ACTIVE;
                return false;
        }
 
+       obj = to_intel_framebuffer(crtc->fb)->obj;
        if (obj->tiling_mode != I915_TILING_X ||
            obj->fence_reg == I915_FENCE_REG_NONE) {
                DRM_DEBUG_KMS("PSR condition failed: fb not tiled or fenced\n");