[Intel-gfx] [PATCH 3/6] drm/i915: combine overflow checks

Matthew Auld matthew.auld at intel.com
Fri Apr 8 09:32:31 UTC 2016


Looks a little neater and ever so slightly reduces the size of the
binary.

Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
Signed-off-by: Matthew Auld <matthew.auld at intel.com>
---
 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);
-- 
2.4.11



More information about the Intel-gfx mailing list