diff options
author | Ma Jun <Jun.Ma2@amd.com> | 2024-05-07 09:29:33 +0800 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2024-05-08 15:17:07 -0400 |
commit | d768394fa99467bcf2703bde74ddc96eeb0b71fa (patch) | |
tree | a0f3fe4927df987f6a3bd9bda3898df89491ff90 /drivers/gpu/drm/amd/amdgpu/df_v1_7.c | |
parent | cdca89bce4984f1bb6e53cd4084820d4ff54f977 (diff) |
drm/amdgpu: Fix out-of-bounds read of df_v1_7_channel_number
Check the fb_channel_number range to avoid the array out-of-bounds
read error
Signed-off-by: Ma Jun <Jun.Ma2@amd.com>
Reviewed-by: Tim Huang <Tim.Huang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/df_v1_7.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/df_v1_7.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/df_v1_7.c b/drivers/gpu/drm/amd/amdgpu/df_v1_7.c index 5dfab80ffff2..cd298556f7a6 100644 --- a/drivers/gpu/drm/amd/amdgpu/df_v1_7.c +++ b/drivers/gpu/drm/amd/amdgpu/df_v1_7.c @@ -70,6 +70,8 @@ static u32 df_v1_7_get_hbm_channel_number(struct amdgpu_device *adev) int fb_channel_number; fb_channel_number = adev->df.funcs->get_fb_channel_number(adev); + if (fb_channel_number >= ARRAY_SIZE(df_v1_7_channel_number)) + fb_channel_number = 0; return df_v1_7_channel_number[fb_channel_number]; } |