From patchwork Tue Apr 26 09:08:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 8936681 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E1A9FBF29F for ; Tue, 26 Apr 2016 09:08:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 11F952014A for ; Tue, 26 Apr 2016 09:08:43 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0652A2010C for ; Tue, 26 Apr 2016 09:08:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E8806E787; Tue, 26 Apr 2016 09:08:39 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 18A386E787 for ; Tue, 26 Apr 2016 09:08:37 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 26 Apr 2016 02:08:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,536,1455004800"; d="scan'208";a="962854529" Received: from unknown (HELO localhost.isw.intel.com) ([10.237.224.82]) by orsmga002.jf.intel.com with ESMTP; 26 Apr 2016 02:08:35 -0700 From: Matthew Auld To: intel-gfx@lists.freedesktop.org Date: Tue, 26 Apr 2016 10:08:07 +0100 Message-Id: <1461661687-23888-1-git-send-email-matthew.auld@intel.com> X-Mailer: git-send-email 2.4.11 Subject: [Intel-gfx] [PATCH] drm/i915: bail in alloc_pdp when !FULL_48BIT_PPGTT X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If we are not in FULL_48BIT_PPGTT mode then we really shouldn't continue on with our allocations, given that the call to free_pdp would bail early without freeing everything, thus leaking memory. v2: (Joonas Lahtinen) - tidy up with goto teardown path v3: (Joonas Lahtinen) - use more appropriate goto label name Cc: Chris Wilson Cc: Joonas Lahtinen Signed-off-by: Matthew Auld Reviewed-by: Joonas Lahtinen --- drivers/gpu/drm/i915/i915_gem_gtt.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index 0d666b3..3ace3d0 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -567,13 +567,16 @@ static struct i915_page_directory_pointer *alloc_pdp(struct drm_device *dev) { struct i915_page_directory_pointer *pdp; - int ret = -ENOMEM; + int ret = -EINVAL; - WARN_ON(!USES_FULL_48BIT_PPGTT(dev)); + if (WARN_ON(!USES_FULL_48BIT_PPGTT(dev))) + goto fail; pdp = kzalloc(sizeof(*pdp), GFP_KERNEL); - if (!pdp) - return ERR_PTR(-ENOMEM); + if (!pdp) { + ret = -ENOMEM; + goto fail; + } ret = __pdp_init(dev, pdp); if (ret) @@ -589,7 +592,7 @@ fail_page_m: __pdp_fini(pdp); fail_bitmap: kfree(pdp); - +fail: return ERR_PTR(ret); }