diff mbox

[4/6] drm/i915: handle potential overflow

Message ID 1460107954-13740-4-git-send-email-matthew.auld@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Matthew Auld April 8, 2016, 9:32 a.m. UTC
Much like with the equivalent gen8_alloc_va_range.

Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Chris Wilson April 8, 2016, 10:28 a.m. UTC | #1
On Fri, Apr 08, 2016 at 10:32:32AM +0100, Matthew Auld wrote:
> Much like with the equivalent gen8_alloc_va_range.

Just delete the warn and make the allocation paths stronger if you feel
paranoid.
-Chris
diff mbox

Patch

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;