Skip to contentSkip to conversation

drm/amdgpu: initialize ret before UMC error record loop

PATCH In review Ruoyu Wang 2 participants 2 messages Jun 20

Subsystems (2)
lore
Share & tools
lore

Ruoyu Wang

author
#0 lore raw

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

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.

---
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(+)
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +1 -0
index db505ab32fa0f..382e6d2dda9c1 100644
@@ -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,
Signature · 1 line
2.51.0
Reviewed-by on v3 1/1
#1 lore raw

AMD General

Quoted 54 lines

-----Original Message-----
From: Ruoyu Wang <[email protected]>
Sent: Saturday, June 20, 2026 2:12 PM
To: Deucher, Alexander <[email protected]>
Cc: Koenig, Christian <[email protected]>; Zhou1, Tao <[email protected]>; Lazar, Lijo <[email protected]>; Zhang, Hawking <[email protected]>; [email protected]; [email protected]; amd- [email protected]; [email protected]; linux- [email protected]; Ruoyu Wang <[email protected]>
Subject: [PATCH v3] drm/amdgpu: initialize ret before UMC error record loop

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

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.

---
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(+)
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +1 -0
index db505ab32fa0f..382e6d2dda9c1 100644
@@ -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