diff options
-rw-r--r-- | drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c index dc2daf780ffd..23b5424c0d67 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c @@ -1529,9 +1529,9 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev) const struct drm_i915_gem_exec_object2 *entry = ev->exec; struct drm_i915_gem_relocation_entry __user *urelocs = u64_to_user_ptr(entry->relocs_ptr); - unsigned long remain = entry->relocation_count; + unsigned int remain = entry->relocation_count; - if (unlikely(remain > N_RELOC(ULONG_MAX))) + if (unlikely(remain > N_RELOC(UINT_MAX))) return -EINVAL; /* @@ -1545,7 +1545,7 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev) do { struct drm_i915_gem_relocation_entry *r = stack; unsigned int count = - min_t(unsigned long, remain, ARRAY_SIZE(stack)); + min_t(unsigned int, remain, ARRAY_SIZE(stack)); unsigned int copied; /* @@ -1639,7 +1639,7 @@ static int check_relocations(const struct drm_i915_gem_exec_object2 *entry) if (size == 0) return 0; - if (size > N_RELOC(ULONG_MAX)) + if (size > N_RELOC(UINT_MAX)) return -EINVAL; addr = u64_to_user_ptr(entry->relocs_ptr); @@ -1667,7 +1667,7 @@ static int eb_copy_relocations(const struct i915_execbuffer *eb) const unsigned int nreloc = eb->exec[i].relocation_count; struct drm_i915_gem_relocation_entry __user *urelocs; unsigned long size; - unsigned long copied; + unsigned int copied; if (nreloc == 0) continue; @@ -1685,19 +1685,8 @@ static int eb_copy_relocations(const struct i915_execbuffer *eb) goto err; } - /* copy_from_user is limited to < 4GiB */ - copied = 0; - do { - unsigned int len = - min_t(u64, BIT_ULL(31), size - copied); - - if (__copy_from_user((char *)relocs + copied, - (char __user *)urelocs + copied, - len)) - goto end; - - copied += len; - } while (copied < size); + if (__copy_from_user(relocs, urelocs, size)) + goto end; /* * As we do not update the known relocation offsets after |