From patchwork Tue Sep 13 13:46:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 114496 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 52E00B70C2 for ; Tue, 13 Sep 2011 23:47:43 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1R3TKU-0000Vv-Gu; Tue, 13 Sep 2011 13:47:14 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1R3TKJ-0000Iv-VJ for kernel-team@lists.ubuntu.com; Tue, 13 Sep 2011 13:47:04 +0000 Received: from c-69-254-227-224.hsd1.ks.comcast.net ([69.254.227.224] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1R3TKJ-0006KO-MZ for kernel-team@lists.ubuntu.com; Tue, 13 Sep 2011 13:47:03 +0000 From: Seth Forshee To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/2][Lucid SRU] drm/i915: Fix refleak during eviction. Date: Tue, 13 Sep 2011 08:46:49 -0500 Message-Id: <1315921609-8875-3-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1315921609-8875-1-git-send-email-seth.forshee@canonical.com> References: <1315921609-8875-1-git-send-email-seth.forshee@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com From: Chris Wilson BugLink: http://bugs.launchpad.net/bugs/843904 Now that we hold onto a reference whilst evicting objects, we need to be sure that we drop all the references taken -- even on the error paths. Signed-off-by: Chris Wilson (backported from commit e39a01501b228e1be2037d5bddccae2a820af902 upstream) Signed-off-by: Seth Forshee --- drivers/gpu/drm/i915/i915_gem_evict.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c index c50c093..9e7f9c6 100644 --- a/drivers/gpu/drm/i915/i915_gem_evict.c +++ b/drivers/gpu/drm/i915/i915_gem_evict.c @@ -65,7 +65,7 @@ i915_gem_evict_something(struct drm_device *dev, int min_size, unsigned alignmen { drm_i915_private_t *dev_priv = dev->dev_private; struct list_head eviction_list, unwind_list; - struct drm_i915_gem_object *obj_priv, *tmp_obj_priv; + struct drm_i915_gem_object *obj_priv; struct list_head *iter; int ret = 0; @@ -157,8 +157,10 @@ found: * scanning, therefore store to be evicted objects on a * temporary list. */ INIT_LIST_HEAD(&eviction_list); - list_for_each_entry_safe(obj_priv, tmp_obj_priv, - &unwind_list, evict_list) { + while (!list_empty(&unwind_list)) { + obj_priv = list_first_entry(&unwind_list, + struct drm_i915_gem_object, + evict_list); if (drm_mm_scan_remove_block(obj_priv->gtt_space)) { list_move(&obj_priv->evict_list, &eviction_list); continue; @@ -179,7 +181,7 @@ found: drm_gem_object_unreference(obj_priv->obj); } - return 0; + return ret; } int