提交 036286e2 编写于 作者: C Colin Ian King 提交者: Alex Deucher

drm/amdgpu/df: fix potential array out-of-bounds read

The comparison with the number of elements in array df_v3_7_channel_number
is off-by-one and can produce an array out-of-bounds read if
fb_channel_number is equal to the number of elements of the array. Fix
this by changing the comparison to >= instead of >.

Detected by CoverityScan, CID#1469489 ("Out-of-bounds read")

Fixes: 13b58150 ("drm/amdgpu/df: implement df v3_6 callback functions (v2)")
Signed-off-by: NColin Ian King <colin.king@canonical.com>
Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
上级 7ba01f9e
...@@ -64,7 +64,7 @@ static u32 df_v3_6_get_hbm_channel_number(struct amdgpu_device *adev) ...@@ -64,7 +64,7 @@ static u32 df_v3_6_get_hbm_channel_number(struct amdgpu_device *adev)
int fb_channel_number; int fb_channel_number;
fb_channel_number = adev->df_funcs->get_fb_channel_number(adev); fb_channel_number = adev->df_funcs->get_fb_channel_number(adev);
if (fb_channel_number > ARRAY_SIZE(df_v3_6_channel_number)) if (fb_channel_number >= ARRAY_SIZE(df_v3_6_channel_number))
fb_channel_number = 0; fb_channel_number = 0;
return df_v3_6_channel_number[fb_channel_number]; return df_v3_6_channel_number[fb_channel_number];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册