Commit e94f7856 authored by Chris Wilson's avatar Chris Wilson
Browse files

drm/i915/gem: Promote 'remain' to unsigned long



Tidy the code by casting remain to unsigned long once for the duration
of eb_relocate_vma()

Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarMika Kuoppala <mika.kuoppala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200407085930.19421-1-chris@chris-wilson.co.uk
parent e6829625
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -1501,13 +1501,12 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
{
#define N_RELOC(x) ((x) / sizeof(struct drm_i915_gem_relocation_entry))
	struct drm_i915_gem_relocation_entry stack[N_RELOC(512)];
	struct drm_i915_gem_relocation_entry __user *urelocs;
	const struct drm_i915_gem_exec_object2 *entry = ev->exec;
	unsigned int remain;
	struct drm_i915_gem_relocation_entry __user *urelocs =
		u64_to_user_ptr(entry->relocs_ptr);
	unsigned long remain = entry->relocation_count;

	urelocs = u64_to_user_ptr(entry->relocs_ptr);
	remain = entry->relocation_count;
	if (unlikely((unsigned long)remain > N_RELOC(ULONG_MAX)))
	if (unlikely(remain > N_RELOC(ULONG_MAX)))
		return -EINVAL;

	/*
@@ -1521,7 +1520,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 int, remain, ARRAY_SIZE(stack));
			min_t(unsigned long, remain, ARRAY_SIZE(stack));
		unsigned int copied;

		/*