drm/i915: Don't try to look up object for non-existent fb
authorMatt Roper <matthew.d.roper@intel.com>
Wed, 25 Jun 2014 00:05:02 +0000 (17:05 -0700)
committerJani Nikula <jani.nikula@intel.com>
Wed, 25 Jun 2014 10:06:35 +0000 (13:06 +0300)
crtc->primary->fb may be NULL upon entry to intel_pipe_set_base() if the
primary plane has previously been disabled via the universal plane
interface.  We need to check for NULL before trying to reference
old_fb's obj.

This fixes a regression introduced in

        commit a071fa00647bc9a3c53f917b236fff9aea175e3a
        Author: Daniel Vetter <daniel.vetter@ffwll.ch>
        Date:   Wed Jun 18 23:28:09 2014 +0200

        drm/i915: Introduce accurate frontbuffer tracking

Testcase: igt/kms_universal_plane
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
drivers/gpu/drm/i915/intel_display.c

index ff63367938268bb5298725c113b4c973695115bc..f4eb752a11745f4eadc56e29da2ff9da8aa19230 100644 (file)
@@ -2690,6 +2690,7 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
        enum pipe pipe = intel_crtc->pipe;
        struct drm_framebuffer *old_fb;
        struct drm_i915_gem_object *obj = to_intel_framebuffer(fb)->obj;
+       struct drm_i915_gem_object *old_obj;
        int ret;
 
        if (intel_crtc_has_pending_flip(crtc)) {
@@ -2711,11 +2712,12 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
        }
 
        old_fb = crtc->primary->fb;
+       old_obj = old_fb ? to_intel_framebuffer(old_fb)->obj : NULL;
 
        mutex_lock(&dev->struct_mutex);
        ret = intel_pin_and_fence_fb_obj(dev, obj, NULL);
        if (ret == 0)
-               i915_gem_track_fb(to_intel_framebuffer(old_fb)->obj, obj,
+               i915_gem_track_fb(old_obj, obj,
                                  INTEL_FRONTBUFFER_PRIMARY(pipe));
        mutex_unlock(&dev->struct_mutex);
        if (ret != 0) {