From patchwork Fri Apr 8 09:32:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 8782291 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 A9AECC0553 for ; Fri, 8 Apr 2016 09:33:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D6B20201B4 for ; Fri, 8 Apr 2016 09:33:20 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D44BD20149 for ; Fri, 8 Apr 2016 09:33:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7FB1F6EA44; Fri, 8 Apr 2016 09:33:19 +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 B13686EA4F for ; Fri, 8 Apr 2016 09:33:18 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP; 08 Apr 2016 02:32:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,449,1455004800"; d="scan'208";a="682909591" Received: from unknown (HELO localhost.isw.intel.com) ([10.237.224.82]) by FMSMGA003.fm.intel.com with ESMTP; 08 Apr 2016 02:32:55 -0700 From: Matthew Auld To: intel-gfx@lists.freedesktop.org Date: Fri, 8 Apr 2016 10:32:31 +0100 Message-Id: <1460107954-13740-3-git-send-email-matthew.auld@intel.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1460107954-13740-1-git-send-email-matthew.auld@intel.com> References: <1460107954-13740-1-git-send-email-matthew.auld@intel.com> Subject: [Intel-gfx] [PATCH 3/6] drm/i915: combine overflow checks 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 Looks a little neater and ever so slightly reduces the size of the binary. Cc: Joonas Lahtinen Signed-off-by: Matthew Auld --- drivers/gpu/drm/i915/i915_gem_gtt.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index 066d5aead..180dbd8 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -1223,10 +1223,7 @@ static int gen8_alloc_va_range_3lvl(struct i915_address_space *vm, /* Wrap is never okay since we can only represent 48b, and we don't * actually use the other side of the canonical address space. */ - if (WARN_ON(start + length < start)) - return -ENODEV; - - if (WARN_ON(start + length > vm->total)) + if (WARN_ON(start > vm->total || length > vm->total - start)) return -ENODEV; ret = alloc_gen8_temp_bitmaps(&new_page_dirs, &new_page_tables, pdpes);