Commit 7ed97155 authored by Yang Wang's avatar Yang Wang Committed by Alex Deucher

drm/amdgpu: fix UBSAN array-index-out-of-bounds for ras_block_string[]

fix array index out of bounds issue for ras_block_string[] array.

Fixes: 30df05fb ("drm/amdgpu: Align ras block enum with firmware")
Signed-off-by: default avatarYang Wang <kevinyang.wang@amd.com>
Reviewed-by: default avatarTao Zhou <tao.zhou1@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent b5387349
...@@ -74,6 +74,8 @@ const char *ras_block_string[] = { ...@@ -74,6 +74,8 @@ const char *ras_block_string[] = {
"mca", "mca",
"vcn", "vcn",
"jpeg", "jpeg",
"ih",
"mpio",
}; };
const char *ras_mca_block_string[] = { const char *ras_mca_block_string[] = {
...@@ -95,7 +97,8 @@ const char *get_ras_block_str(struct ras_common_if *ras_block) ...@@ -95,7 +97,8 @@ const char *get_ras_block_str(struct ras_common_if *ras_block)
if (!ras_block) if (!ras_block)
return "NULL"; return "NULL";
if (ras_block->block >= AMDGPU_RAS_BLOCK_COUNT) if (ras_block->block >= AMDGPU_RAS_BLOCK_COUNT ||
ras_block->block >= ARRAY_SIZE(ras_block_string))
return "OUT OF RANGE"; return "OUT OF RANGE";
if (ras_block->block == AMDGPU_RAS_BLOCK__MCA) if (ras_block->block == AMDGPU_RAS_BLOCK__MCA)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment