drm/amdgpu: Fix out-of-bounds read of df_v1_7_channel_number
authorjsg <jsg@openbsd.org>
Mon, 9 Sep 2024 09:19:49 +0000 (09:19 +0000)
committerjsg <jsg@openbsd.org>
Mon, 9 Sep 2024 09:19:49 +0000 (09:19 +0000)
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

index 5dfab80..cd29855 100644 (file)
@@ -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];
 }