From patchwork Fri Apr 22 11:05:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 8909711 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8121D9F1D3 for ; Fri, 22 Apr 2016 11:05:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9667B20149 for ; Fri, 22 Apr 2016 11:05:46 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 5E2C3201BB for ; Fri, 22 Apr 2016 11:05:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 93EB86EE8D; Fri, 22 Apr 2016 11:05:44 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTP id 274786EE8D for ; Fri, 22 Apr 2016 11:05:42 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP; 22 Apr 2016 04:05:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,516,1455004800"; d="scan'208";a="690436158" Received: from odrizin-mobl7.ger.corp.intel.com (HELO vmiceli-mobl2.amr.corp.intel.com) ([10.252.10.56]) by FMSMGA003.fm.intel.com with ESMTP; 22 Apr 2016 04:05:40 -0700 From: Matthew Auld To: intel-gfx@lists.freedesktop.org Date: Fri, 22 Apr 2016 12:05:37 +0100 Message-Id: <1461323137-21045-1-git-send-email-matthew.auld@intel.com> X-Mailer: git-send-email 2.5.5 Subject: [Intel-gfx] [PATCH 2/3] 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 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..f996f4b 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; pdp = kzalloc(sizeof(*pdp), GFP_KERNEL); - if (!pdp) - return ERR_PTR(-ENOMEM); + if (!pdp) { + ret = -ENOMEM; + goto fail_pdp; + } ret = __pdp_init(dev, pdp); if (ret) @@ -589,7 +592,7 @@ fail_page_m: __pdp_fini(pdp); fail_bitmap: kfree(pdp); - +fail_pdp: return ERR_PTR(ret); }