[PATCH] drm/i915/gem: Add a check for object size for corner cases

Anand Moon anandx.ram.moon at intel.com
Wed Feb 10 07:59:29 UTC 2021


Add check for object size to return appropriate error -E2BIG or -EINVAL
to avoid WARM_ON and sucessfull return for some testcase.

Cc: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld at intel.com>
Signed-off-by: Anand Moon <anandx.ram.moon at intel.com>
---
VLK-17702: Since these object size is U64 these corner case will not come
into real test senario.

IGT testcase:
sudo ./gem_create --r create-massive
sudo ./gem_userptr_blits --r input-checking
---
 drivers/gpu/drm/i915/gem/i915_gem_object.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h b/drivers/gpu/drm/i915/gem/i915_gem_object.h
index 366d23afbb1a..afc37546da20 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h
@@ -33,6 +33,9 @@ static inline bool i915_gem_object_size_2big(u64 size)
 {
 	struct drm_i915_gem_object *obj;
 
+	if (size == -1 || size == (-1ull << 32))
+		return true;
+
 	if (GEM_CHECK_SIZE_OVERFLOW(size))
 		return true;
 
-- 
2.30.0



More information about the dri-devel mailing list