Re: [PATCH 1/2] drm/amdgpu: initialize r in amdgpu_vm_bo_update()

From: Christian König

Date: Fri Nov 20 2026 - 07:08:17 EST




On 11/19/26 18:07, Ian Rogers wrote:
> Commit bc566781845b ("drm/amdgpu: stop syncing PRT map operations") added
> an 'else if (!bo)' branch in amdgpu_vm_bo_update() that does not assign
> 'r'. Because fpriv->prt_va has bo == NULL and is updated on every command
> submission, userqueue validation, and KFD VM restore, calling
> amdgpu_vm_bo_update(adev, fpriv->prt_va, false) when bo_va->invalids is
> empty skips the mapping loop and returns uninitialized stack variable 'r'.
>
> 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: bc566781845b ("drm/amdgpu: stop syncing PRT map operations")
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 82b9b2d5d0cf..091589b2c524 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -1303,7 +1303,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
> uint64_t vram_base;
> uint64_t flags;
> bool uncached;
> - int r;
> + int r = 0;

Good catch, but please don't initialize return variables a default value.

That is often seen as bad coding style and often hides problems instead of fixing them.

Instead just initialize r in the if branch where it is missing.

Thanks,
Christian.

>
> amdgpu_sync_create(&sync);
> if (clear) {