Re: [PATCH 2/2] drm/amdgpu: initialize r in amdgpu_ttm_clear_buffer()
From: Christian König
Date: Fri Nov 20 2026 - 07:12:44 EST
On 11/19/26 18:07, Ian Rogers wrote:
> In amdgpu_ttm_clear_buffer(), 'r' is declared uninitialized. When
> consider_clear_status is true (such as AMDGPU_GEM_CREATE_VRAM_CLEARED
> allocations) and all backing buddy blocks already have DRM_BUDDY_CLEARED
> set, every iteration of the cursor loop hits 'continue' without assigning
> 'r', returning uninitialized stack memory to amdgpu_bo_create().
>
> Initialize 'r' to 0.
>
> Found via an x86_64 LLVM=1 (Clang 21.1.8) allyesconfig audit with
> -Wconditional-uninitialized enabled; fix and changelog drafted with an AI
> coding assistant. Build-tested under LLVM=1 W=1 (-Werror) and
> -Wconditional-uninitialized; not runtime-tested on AMD GPU hardware.
>
> Fixes: 23bd7e67961e ("drm/amdgpu: get rid of amdgpu_ttm_clear_buffer")
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 0f86777250fc..280fcdfb9cca 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -2675,7 +2675,7 @@ int amdgpu_ttm_clear_buffer(struct amdgpu_ttm_buffer_entity *entity,
> struct dma_fence *fence = NULL;
> struct amdgpu_res_cursor dst;
> bool vm_needs_flush = false;
> - int r;
> + int r = 0;
Please initialize r directly before the error label, apart from that looks good to me.
Regards,
Christian.
>
> if (!entity)
> return -EINVAL;