From 4bb790702424c865a97c1867572dd77a45e3a289 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 8 Jan 2010 14:03:08 +0000 Subject: [PATCH] drm/i915: Clear unpin_work along error path. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The locally allocated unpin_work was being freed along the error path, but we forgot that we had already set the dev_priv->unpin_work to the now freed structure. So remember to clear that pointer along the error path as well. Signed-off-by: Chris Wilson Cc: Jesse Barnes Cc: Kristian Høgsberg --- drivers/gpu/drm/i915/intel_display.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index c7502b6..77d8732 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -4226,8 +4226,6 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, if (work == NULL) return -ENOMEM; - mutex_lock(&dev->struct_mutex); - work->event = event; work->dev = crtc->dev; intel_fb = to_intel_framebuffer(crtc->fb); @@ -4240,7 +4238,6 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, DRM_DEBUG_DRIVER("flip queue: crtc already busy\n"); spin_unlock_irqrestore(&dev->event_lock, flags); kfree(work); - mutex_unlock(&dev->struct_mutex); return -EBUSY; } intel_crtc->unpin_work = work; @@ -4249,13 +4246,18 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, intel_fb = to_intel_framebuffer(fb); obj = intel_fb->obj; + mutex_lock(&dev->struct_mutex); ret = intel_pin_and_fence_fb_obj(dev, obj); if (ret != 0) { DRM_DEBUG_DRIVER("flip queue: %p pin & fence failed\n", - to_intel_bo(obj)); - kfree(work); - intel_crtc->unpin_work = NULL; + to_intel_bo(obj)); mutex_unlock(&dev->struct_mutex); + + spin_lock_irqsave(&dev->event_lock, flags); + intel_crtc->unpin_work = NULL; + spin_unlock_irqrestore(&dev->event_lock, flags); + + kfree(work); return ret; } -- 1.7.1