[PATCH v3 4/4] drm/i915: Use dedicated return variable in eb_relocate_vma()

Sebastian Brzezinka sebastian.brzezinka at intel.com
Fri Jul 18 10:28:26 UTC 2025


Introduce a separate `ret` variable to hold the return value in
`eb_relocate_vma()`, instead of overloading `remain` for both loop
control and error reporting.

Signed-off-by: Sebastian Brzezinka <sebastian.brzezinka at intel.com>
---
v2 -> v3:
	- Split commit to isolate individual changes
---
 drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index e66d2f60f23b..b737acf74439 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -1530,6 +1530,7 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
 	struct drm_i915_gem_relocation_entry __user *urelocs =
 		u64_to_user_ptr(entry->relocs_ptr);
 	unsigned long remain = entry->relocation_count;
+	int ret = 0;
 
 	if (unlikely(remain > N_RELOC(INT_MAX)))
 		return -EINVAL;
@@ -1560,7 +1561,7 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
 		copied = __copy_from_user_inatomic(r, urelocs, count * sizeof(r[0]));
 		pagefault_enable();
 		if (unlikely(copied)) {
-			remain = -EFAULT;
+			ret = -EFAULT;
 			goto out;
 		}
 
@@ -1572,7 +1573,7 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
 				continue;
 
 			if ((s64)offset < 0) {
-				remain = (int)offset;
+				ret = offset;
 				goto out;
 			}
 			/*
@@ -1603,7 +1604,7 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
 	} while (remain);
 out:
 	reloc_cache_reset(&eb->reloc_cache, eb);
-	return remain;
+	return ret;
 }
 
 static int
-- 
2.34.1



More information about the Intel-gfx mailing list