[PATCH 1/3] drm/i915: Fix types in relocation paths

Tvrtko Ursulin tursulin at ursulin.net
Wed May 31 13:22:42 UTC 2017


From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

We have signedness mismatches in a few places where 32-bit
unsigned uAPI inputs are internally assigned and handled as
signed 32-bit.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 04211c970b9f..ee269de7d778 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -646,7 +646,8 @@ i915_gem_execbuffer_relocate_vma(struct i915_vma *vma,
 	struct drm_i915_gem_relocation_entry __user *user_relocs;
 	struct drm_i915_gem_exec_object2 *entry = vma->exec_entry;
 	struct reloc_cache cache;
-	int remain, ret = 0;
+	unsigned int remain;
+	int ret = 0;
 
 	user_relocs = u64_to_user_ptr(entry->relocs_ptr);
 	reloc_cache_init(&cache, eb->i915);
@@ -722,7 +723,8 @@ i915_gem_execbuffer_relocate_vma_slow(struct i915_vma *vma,
 {
 	const struct drm_i915_gem_exec_object2 *entry = vma->exec_entry;
 	struct reloc_cache cache;
-	int i, ret = 0;
+	unsigned int i;
+	int ret = 0;
 
 	reloc_cache_init(&cache, eb->i915);
 	for (i = 0; i < entry->relocation_count; i++) {
@@ -995,13 +997,14 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev,
 				  struct drm_i915_gem_exec_object2 *exec,
 				  struct i915_gem_context *ctx)
 {
+	unsigned count = args->buffer_count;
 	struct drm_i915_gem_relocation_entry *reloc;
 	struct i915_address_space *vm;
 	struct i915_vma *vma;
 	bool need_relocs;
-	int *reloc_offset;
-	int i, total, ret;
-	unsigned count = args->buffer_count;
+	unsigned int *reloc_offset;
+	unsigned int i, total;
+	int ret;
 
 	vm = list_first_entry(&eb->vmas, struct i915_vma, exec_list)->vm;
 
@@ -1032,7 +1035,7 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev,
 	for (i = 0; i < count; i++) {
 		struct drm_i915_gem_relocation_entry __user *user_relocs;
 		u64 invalid_offset = (u64)-1;
-		int j;
+		unsigned int j;
 
 		user_relocs = u64_to_user_ptr(exec[i].relocs_ptr);
 
@@ -1085,7 +1088,7 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev,
 		goto err;
 
 	list_for_each_entry(vma, &eb->vmas, exec_list) {
-		int offset = vma->exec_entry - exec;
+		unsigned int offset = vma->exec_entry - exec;
 		ret = i915_gem_execbuffer_relocate_vma_slow(vma, eb,
 							    reloc + reloc_offset[offset]);
 		if (ret)
@@ -1173,12 +1176,12 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
 static int
 validate_exec_list(struct drm_device *dev,
 		   struct drm_i915_gem_exec_object2 *exec,
-		   int count)
+		   unsigned int count)
 {
 	unsigned relocs_total = 0;
 	unsigned relocs_max = UINT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
 	unsigned invalid_flags;
-	int i;
+	unsigned int i;
 
 	/* INTERNAL flags must not overlap with external ones */
 	BUILD_BUG_ON(__EXEC_OBJECT_INTERNAL_FLAGS & ~__EXEC_OBJECT_UNKNOWN_FLAGS);
-- 
2.9.4



More information about the Intel-gfx-trybot mailing list