From c73391c5898f206abc4ba8ccd2d1f4437c42aec3 Mon Sep 17 00:00:00 2001 From: Karl Mehltretter Date: Mon, 14 Sep 2026 07:46:04 +0200 Subject: [PATCH] drm/amdgpu: Initialize UALink handle uniqueness state amdgpu_generate_ualink_handle() continues when handle_lo is zero. For accelerator ID 0, the random value can become zero after the low 10 bits are cleared. This path reaches while (!unique) without assigning unique. Clang's -Wconditional-uninitialized reports the read. A reduced MemorySanitizer test reports use-of-uninitialized-value at the loop condition. If the uninitialized value ends the loop, handle 0 is inserted into exp_xa while robj->ualink_handle_lo still says that the BO has no handle. A later export can create another entry for the same BO. Initialize unique to false so the zero-handle path repeats the loop. Fixes: c67cb19811ec ("drm/amdgpu: Implement UALink handle export") Assisted-by: LLM Signed-off-by: Karl Mehltretter Signed-off-by: Felix Kuehling Reviewed-by: Felix Kuehling Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c index 35aabc4c4526..0d16047dca67 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c @@ -1822,7 +1822,7 @@ static void amdgpu_ualink_npa_mm_fini(struct amdgpu_device *adev) static void amdgpu_generate_ualink_handle(struct amdgpu_device *adev, struct amdgpu_ualink_handle *handle) { - bool unique; + bool unique = false; do { handle->handle_lo = get_random_u64();