* [PATCH v2 0/2] drm/amdgpu: Initialize r in VM and TTM buffer helpers
@ 2026-11-22 4:53 Ian Rogers
2026-11-22 4:53 ` [PATCH v2 1/2] drm/amdgpu: initialize r in amdgpu_vm_bo_update() Ian Rogers
2026-11-22 4:53 ` [PATCH v2 2/2] drm/amdgpu: initialize r in amdgpu_ttm_clear_buffer() Ian Rogers
0 siblings, 2 replies; 3+ messages in thread
From: Ian Rogers @ 2026-11-22 4:53 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter
Cc: amd-gfx, dri-devel, linux-kernel, llvm, Elkin Cruz, Ian Rogers
Two fixes in drm/amdgpu for uninitialized return-value regressions
found via Clang -Wconditional-uninitialized on an x86_64
allyesconfig build:
1. Set r = 0 in the 'else if (!bo)' branch of amdgpu_vm_bo_update().
2. Set r = 0 right after the while loop before 'error:' in
amdgpu_ttm_clear_buffer().
Build-tested with LLVM=1 W=1 (-Werror) and -Wconditional-uninitialized;
not runtime-tested on AMDGPU hardware.
v2:
- Keep 'int r;' uninitialized at declaration in both functions so
future missing-assignment paths are not masked; instead set 'r = 0;'
inside 'else if (!bo)' in patch 1/2 and directly before 'error:' in
patch 2/2 (Christian König).
v1: https://lore.kernel.org/r/cover.1795106955.git.irogers@google.com
Ian Rogers (2):
drm/amdgpu: initialize r in amdgpu_vm_bo_update()
drm/amdgpu: initialize r in amdgpu_ttm_clear_buffer()
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 ++
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 1 +
2 files changed, 3 insertions(+)
--
2.56.1.750.gf70dc682cf-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/2] drm/amdgpu: initialize r in amdgpu_vm_bo_update()
2026-11-22 4:53 [PATCH v2 0/2] drm/amdgpu: Initialize r in VM and TTM buffer helpers Ian Rogers
@ 2026-11-22 4:53 ` Ian Rogers
2026-11-22 4:53 ` [PATCH v2 2/2] drm/amdgpu: initialize r in amdgpu_ttm_clear_buffer() Ian Rogers
1 sibling, 0 replies; 3+ messages in thread
From: Ian Rogers @ 2026-11-22 4:53 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter
Cc: amd-gfx, dri-devel, linux-kernel, llvm, Elkin Cruz, Ian Rogers
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'.
Set 'r = 0' in the 'else if (!bo)' branch.
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@google.com>
---
Notes:
v2:
- Set 'r = 0;' in the 'else if (!bo)' branch instead of initializing 'r'
at declaration (Christian König).
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 82b9b2d5d0cf..d36ce2748f72 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1323,6 +1323,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
}
} else if (!bo) {
mem = NULL;
+ r = 0;
/* PRT map operations don't need to sync to anything. */
--
2.56.1.750.gf70dc682cf-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] drm/amdgpu: initialize r in amdgpu_ttm_clear_buffer()
2026-11-22 4:53 [PATCH v2 0/2] drm/amdgpu: Initialize r in VM and TTM buffer helpers Ian Rogers
2026-11-22 4:53 ` [PATCH v2 1/2] drm/amdgpu: initialize r in amdgpu_vm_bo_update() Ian Rogers
@ 2026-11-22 4:53 ` Ian Rogers
1 sibling, 0 replies; 3+ messages in thread
From: Ian Rogers @ 2026-11-22 4:53 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter
Cc: amd-gfx, dri-devel, linux-kernel, llvm, Elkin Cruz, Ian Rogers
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().
Set 'r = 0' after the cursor loop directly before the 'error:' label.
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@google.com>
---
Notes:
v2:
- Set 'r = 0;' directly before the 'error:' label instead of
initializing 'r' at declaration (Christian König).
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 0f86777250fc..693f25285f2f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -2711,6 +2711,8 @@ int amdgpu_ttm_clear_buffer(struct amdgpu_ttm_buffer_entity *entity,
amdgpu_res_next(&dst, cur_size);
}
+ r = 0;
+
error:
mutex_unlock(&entity->lock);
*out_fence = fence;
--
2.56.1.750.gf70dc682cf-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-22 4:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-22 4:53 [PATCH v2 0/2] drm/amdgpu: Initialize r in VM and TTM buffer helpers Ian Rogers
2026-11-22 4:53 ` [PATCH v2 1/2] drm/amdgpu: initialize r in amdgpu_vm_bo_update() Ian Rogers
2026-11-22 4:53 ` [PATCH v2 2/2] drm/amdgpu: initialize r in amdgpu_ttm_clear_buffer() Ian Rogers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox