diff mbox series

[SRU,F,1/1] drm/amdgpu: Fix out-of-bounds read of df_v1_7_channel_number

Message ID 20241016170836.30797-3-bethany.jamison@canonical.com
State New
Headers show
Series [SRU,F,1/1] drm/amdgpu: Fix out-of-bounds read of df_v1_7_channel_number | expand

Commit Message

Bethany Jamison Oct. 16, 2024, 5:08 p.m. UTC
From: Ma Jun <Jun.Ma2@amd.com>

[ Upstream commit d768394fa99467bcf2703bde74ddc96eeb0b71fa ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(backported from commit 725b728cc0c8c5fafdfb51cb0937870d33a40fa4 linux-5.10.y)
[bjamison: kept 'df_funcs' instead of backporting commit bdf84a80e0ce5f60f4f41
and using 'df.funcs']
CVE-2024-46724
Signed-off-by: Bethany Jamison <bethany.jamison@canonical.com>
---
 drivers/gpu/drm/amd/amdgpu/df_v1_7.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/df_v1_7.c b/drivers/gpu/drm/amd/amdgpu/df_v1_7.c
index 844c038682485..8f80fc5712268 100644
--- a/drivers/gpu/drm/amd/amdgpu/df_v1_7.c
+++ b/drivers/gpu/drm/amd/amdgpu/df_v1_7.c
@@ -63,6 +63,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];
 }