diff options
author | Colin Ian King <colin.king@canonical.com> | 2018-05-30 12:41:44 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-06-01 10:45:05 -0400 |
commit | 036286e28e8ece7637cc62934f7dbc89e6656940 (patch) | |
tree | 28d73323c6b2e426253b7b26a5d6702e669ddc8e | |
parent | 7ba01f9e12bb3f088f617cf69b589ea37bd5d6ed (diff) |
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: 13b581502d51 ("drm/amdgpu/df: implement df v3_6 callback functions (v2)")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/df_v3_6.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/df_v3_6.c b/drivers/gpu/drm/amd/amdgpu/df_v3_6.c index 60608b3df881..d5ebe566809b 100644 --- a/drivers/gpu/drm/amd/amdgpu/df_v3_6.c +++ b/drivers/gpu/drm/amd/amdgpu/df_v3_6.c | |||
@@ -64,7 +64,7 @@ static u32 df_v3_6_get_hbm_channel_number(struct amdgpu_device *adev) | |||
64 | int fb_channel_number; | 64 | int fb_channel_number; |
65 | 65 | ||
66 | fb_channel_number = adev->df_funcs->get_fb_channel_number(adev); | 66 | fb_channel_number = adev->df_funcs->get_fb_channel_number(adev); |
67 | if (fb_channel_number > ARRAY_SIZE(df_v3_6_channel_number)) | 67 | if (fb_channel_number >= ARRAY_SIZE(df_v3_6_channel_number)) |
68 | fb_channel_number = 0; | 68 | fb_channel_number = 0; |
69 | 69 | ||
70 | return df_v3_6_channel_number[fb_channel_number]; | 70 | return df_v3_6_channel_number[fb_channel_number]; |