The loop iterated only AMDGPU_MAX_MES_PIPES times, leaving entries
uninitialized for multi-XCC GPUs. This causes null pointer dereferences
when accessing arrays indexed by XCC ID >= 2. Extend the loop to cover
all XCCs (AMDGPU_MAX_MES_PIPES * num_xcc), matching other per-XCC
arrays.

Fixes: 723b3bc87afb ("drm/amdgpu: Fixup boost mes detect hang array size")
Signed-off-by: Geoffrey McRae <[email protected]>
Cc: Alex Deucher <[email protected]>
Cc: Christian König <[email protected]>
Cc: Amber Lin <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
index 6c0dde3786e3..6ec4f1d537d2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
@@ -237,7 +237,7 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
        }
 
        if (adev->mes.hung_queue_db_array_size) {
-               for (i = 0; i < AMDGPU_MAX_MES_PIPES; i++) {
+               for (i = 0; i < AMDGPU_MAX_MES_PIPES * num_xcc; i++) {
                        r = amdgpu_bo_create_kernel(adev,
                                                    
adev->mes.hung_queue_db_array_size * sizeof(u32),
                                                    PAGE_SIZE,
-- 
2.43.0

Reply via email to