summaryrefslogtreecommitdiff
path: root/drivers/gpu
diff options
context:
space:
mode:
authorGeoffrey McRae <geoffrey.mcrae@amd.com>2026-06-28 16:17:01 +1000
committerAlex Deucher <alexander.deucher@amd.com>2026-07-08 14:20:29 -0400
commitf3f622b43edc86a4ae00f521789a5d24bb71a761 (patch)
tree87cf3241e6a0484e6cce7ec890675a8fdfa5a263 /drivers/gpu
parentf4c7d8293f019bccb7211ce312559715b51c5094 (diff)
drm/amdgpu/mes: Add NULL check for mes_hung_db_array allocation
kcalloc but does not check for failure. If the allocation fails, the pointer remains NULL but the function returns success. Subsequent code using this buffer will dereference a NULL pointer, causing a kernel oops. Add a check to return -ENOMEM if the allocation fails. Signed-off-by: Geoffrey McRae <geoffrey.mcrae@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Cc: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
index 6c0dde3786e3..261ddc19c840 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
@@ -250,11 +250,16 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
goto error_doorbell;
}
}
- }
- adev->gfx.mec.mes_hung_db_array =
- kcalloc(amdgpu_mes_get_hung_queue_db_array_size(adev),
- sizeof(u32), GFP_KERNEL);
+ adev->gfx.mec.mes_hung_db_array =
+ kcalloc(amdgpu_mes_get_hung_queue_db_array_size(adev),
+ sizeof(u32), GFP_KERNEL);
+
+ if (!adev->gfx.mec.mes_hung_db_array) {
+ r = -ENOMEM;
+ goto error_doorbell;
+ }
+ }
return 0;