Commit df0a9bd9 authored by Ma Jun's avatar Ma Jun Committed by Alex Deucher

drm/amdgpu/pm: Check input value for CUSTOM profile mode setting on legacy SOCs

Check the input value for CUSTOM profile mode setting on legacy
SOCs. Otherwise we may use uninitalized value of input[]
Signed-off-by: default avatarMa Jun <Jun.Ma2@amd.com>
Reviewed-by: default avatarYang Wang <kevinyang.wang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent e22e0e48
...@@ -5647,7 +5647,7 @@ static int smu7_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, uint ...@@ -5647,7 +5647,7 @@ static int smu7_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, uint
mode = input[size]; mode = input[size];
switch (mode) { switch (mode) {
case PP_SMC_POWER_PROFILE_CUSTOM: case PP_SMC_POWER_PROFILE_CUSTOM:
if (size < 8 && size != 0) if (size != 8 && size != 0)
return -EINVAL; return -EINVAL;
/* If only CUSTOM is passed in, use the saved values. Check /* If only CUSTOM is passed in, use the saved values. Check
* that we actually have a CUSTOM profile by ensuring that * that we actually have a CUSTOM profile by ensuring that
......
...@@ -4102,9 +4102,11 @@ static int vega20_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, ui ...@@ -4102,9 +4102,11 @@ static int vega20_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, ui
if (power_profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) { if (power_profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) {
struct vega20_hwmgr *data = struct vega20_hwmgr *data =
(struct vega20_hwmgr *)(hwmgr->backend); (struct vega20_hwmgr *)(hwmgr->backend);
if (size == 0 && !data->is_custom_profile_set)
if (size != 10 && size != 0)
return -EINVAL; return -EINVAL;
if (size < 10 && size != 0)
if (size == 0 && !data->is_custom_profile_set)
return -EINVAL; return -EINVAL;
result = vega20_get_activity_monitor_coeff(hwmgr, result = vega20_get_activity_monitor_coeff(hwmgr,
...@@ -4166,6 +4168,8 @@ static int vega20_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, ui ...@@ -4166,6 +4168,8 @@ static int vega20_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, ui
activity_monitor.Fclk_PD_Data_error_coeff = input[8]; activity_monitor.Fclk_PD_Data_error_coeff = input[8];
activity_monitor.Fclk_PD_Data_error_rate_coeff = input[9]; activity_monitor.Fclk_PD_Data_error_rate_coeff = input[9];
break; break;
default:
return -EINVAL;
} }
result = vega20_set_activity_monitor_coeff(hwmgr, result = vega20_set_activity_monitor_coeff(hwmgr,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment