aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRex Zhu <Rex.Zhu@amd.com>2016-11-14 03:36:08 -0500
committerAlex Deucher <alexander.deucher@amd.com>2016-11-16 14:26:17 -0500
commitda7800a88c5a3b798f763d6f9f343e9a49860c4f (patch)
treede398d00481f3a7cfe880359dc774e9c74889e46
parent1da2c326e43b0834105993d13610647337bbad67 (diff)
drm/amd/powerplay: avoid out of bounds access on array ps.
check array index first and then visit the array. Signed-off-by: Rex Zhu <Rex.Zhu@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
index 13f2b705ea49..08cd0bd3ebe5 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
@@ -2984,19 +2984,19 @@ static int smu7_get_pp_table_entry_callback_func_v0(struct pp_hwmgr *hwmgr,
2984 if (!(data->mc_micro_code_feature & DISABLE_MC_LOADMICROCODE) && memory_clock > data->highest_mclk) 2984 if (!(data->mc_micro_code_feature & DISABLE_MC_LOADMICROCODE) && memory_clock > data->highest_mclk)
2985 data->highest_mclk = memory_clock; 2985 data->highest_mclk = memory_clock;
2986 2986
2987 performance_level = &(ps->performance_levels
2988 [ps->performance_level_count++]);
2989
2990 PP_ASSERT_WITH_CODE( 2987 PP_ASSERT_WITH_CODE(
2991 (ps->performance_level_count < smum_get_mac_definition(hwmgr->smumgr, SMU_MAX_LEVELS_GRAPHICS)), 2988 (ps->performance_level_count < smum_get_mac_definition(hwmgr->smumgr, SMU_MAX_LEVELS_GRAPHICS)),
2992 "Performance levels exceeds SMC limit!", 2989 "Performance levels exceeds SMC limit!",
2993 return -EINVAL); 2990 return -EINVAL);
2994 2991
2995 PP_ASSERT_WITH_CODE( 2992 PP_ASSERT_WITH_CODE(
2996 (ps->performance_level_count <= 2993 (ps->performance_level_count <
2997 hwmgr->platform_descriptor.hardwareActivityPerformanceLevels), 2994 hwmgr->platform_descriptor.hardwareActivityPerformanceLevels),
2998 "Performance levels exceeds Driver limit!", 2995 "Performance levels exceeds Driver limit, Skip!",
2999 return -EINVAL); 2996 return 0);
2997
2998 performance_level = &(ps->performance_levels
2999 [ps->performance_level_count++]);
3000 3000
3001 /* Performance levels are arranged from low to high. */ 3001 /* Performance levels are arranged from low to high. */
3002 performance_level->memory_clock = memory_clock; 3002 performance_level->memory_clock = memory_clock;