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

From: Zhou1, Tao

Date: Sat Jun 20 2026 - 09:28:59 EST


AMD General

Reviewed-by: Tao Zhou <tao.zhou1@xxxxxxx>

> -----Original Message-----
> From: Ruoyu Wang <ruoyuw560@xxxxxxxxx>
> Sent: Saturday, June 20, 2026 2:12 PM
> To: Deucher, Alexander <Alexander.Deucher@xxxxxxx>
> Cc: Koenig, Christian <Christian.Koenig@xxxxxxx>; Zhou1, Tao
> <Tao.Zhou1@xxxxxxx>; Lazar, Lijo <Lijo.Lazar@xxxxxxx>; Zhang, Hawking
> <Hawking.Zhang@xxxxxxx>; airlied@xxxxxxxxx; simona@xxxxxxxx; amd-
> gfx@xxxxxxxxxxxxxxxxxxxxx; dri-devel@xxxxxxxxxxxxxxxxxxxxx; linux-
> kernel@xxxxxxxxxxxxxxx; Ruoyu Wang <ruoyuw560@xxxxxxxxx>
> Subject: [PATCH v3] drm/amdgpu: initialize ret before UMC error record loop
>
> [You don't often get email from ruoyuw560@xxxxxxxxx. 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.
>
> 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