[PATCH v3] drm/amdgpu: initialize ret before UMC error record loop

From: Ruoyu Wang

Date: Sat Jun 20 2026 - 02:12:15 EST


umc_v12_0_fill_error_record() returns ret after walking the pages
reported by amdgpu_umc_lookup_bad_pages_in_a_row(). That helper can
return zero entries, leaving the loop skipped and ret uninitialized.

Initialize ret to -EINVAL immediately before the loop so the zero-entry
path returns a deterministic error status while preserving the existing
loop behavior when at least one page is processed.

Suggested-by: Christian König <christian.koenig@xxxxxxx>
Suggested-by: Tao Zhou <tao.zhou1@xxxxxxx>
Signed-off-by: Ruoyu Wang <ruoyuw560@xxxxxxxxx>
---
v3:
- Initialize ret to -EINVAL instead of 0 to match the original error
semantics preferred by Tao Zhou.

v2:
- Set ret immediately before the loop instead of initializing it in the
declaration, as suggested by Christian.
- Avoid describing the zero-entry case as an allocation-failure fix.

drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/umc_v12_0.c b/drivers/gpu/drm/amd/amdgpu/umc_v12_0.c
index db505ab32fa0f..382e6d2dda9c1 100644
--- a/drivers/gpu/drm/amd/amdgpu/umc_v12_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/umc_v12_0.c
@@ -689,6 +689,7 @@ static int umc_v12_0_fill_error_record(struct amdgpu_device *adev,
count = amdgpu_umc_lookup_bad_pages_in_a_row(adev,
ecc_err->pa_pfn << AMDGPU_GPU_PAGE_SHIFT,
page_pfn, ARRAY_SIZE(page_pfn));
+ ret = -EINVAL;

for (i = 0; i < count; i++) {
ret = amdgpu_umc_fill_error_record(err_data,
--
2.51.0