From 596a3c2efe3ccff4296542362fff7f2071764a19 Mon Sep 17 00:00:00 2001 From: jsg Date: Mon, 9 Sep 2024 09:19:49 +0000 Subject: [PATCH] drm/amdgpu: Fix out-of-bounds read of df_v1_7_channel_number From Ma Jun f9267972490f9fcffe146e79828e97acc0da588c in linux-6.6.y/6.6.50 d768394fa99467bcf2703bde74ddc96eeb0b71fa in mainline linux --- sys/dev/pci/drm/amd/amdgpu/df_v1_7.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/dev/pci/drm/amd/amdgpu/df_v1_7.c b/sys/dev/pci/drm/amd/amdgpu/df_v1_7.c index 5dfab80ffff..cd298556f7a 100644 --- a/sys/dev/pci/drm/amd/amdgpu/df_v1_7.c +++ b/sys/dev/pci/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]; } -- 2.20.1