[Intel-gfx] [PATCH 4/6] drm/i915: handle potential overflow

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


Much like with the equivalent gen8_alloc_va_range.

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 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 180dbd8..5589a8d 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -1857,7 +1857,8 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
 	uint32_t pde, temp;
 	int ret;
 
-	if (WARN_ON(start_in + length_in > ppgtt->base.total))
+	if (WARN_ON(start_in > ppgtt->base.total || length_in >
+		    ppgtt->base.total - start_in))
 		return -ENODEV;
 
 	start = start_save = start_in;
-- 
2.4.11



More information about the Intel-gfx mailing list