diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2024-09-09 09:28:28 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2024-09-09 09:28:28 +0000 |
commit | 3fb2016c876df654c44ec4e71446f605fd477a3b (patch) | |
tree | d1232bb5b864b66504c719b7cee08ae000802bce /sys | |
parent | 78237b7992c7d9dfc7567a3b1cc826ea7886e016 (diff) |
drm/amdgpu/pm: Check input value for CUSTOM profile mode setting on legacy SOCs
From Ma Jun
58350786dbbddfb5ffcbb0ef976b5c9fef5870bc in linux-6.6.y/6.6.50
df0a9bd92fbbd3fcafcb2bce6463c9228a3e6868 in mainline linux
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c | 2 | ||||
-rw-r--r-- | sys/dev/pci/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c b/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c index 4cd7e0e270d..bda5f1632c1 100644 --- a/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c +++ b/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c @@ -5641,7 +5641,7 @@ static int smu7_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, uint mode = input[size]; switch (mode) { case PP_SMC_POWER_PROFILE_CUSTOM: - if (size < 8 && size != 0) + if (size != 8 && size != 0) return -EINVAL; /* If only CUSTOM is passed in, use the saved values. Check * that we actually have a CUSTOM profile by ensuring that diff --git a/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c b/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c index bd144d662b7..980364382bd 100644 --- a/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c +++ b/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c @@ -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) { struct vega20_hwmgr *data = (struct vega20_hwmgr *)(hwmgr->backend); - if (size == 0 && !data->is_custom_profile_set) + + if (size != 10 && size != 0) return -EINVAL; - if (size < 10 && size != 0) + + if (size == 0 && !data->is_custom_profile_set) return -EINVAL; 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 activity_monitor.Fclk_PD_Data_error_coeff = input[8]; activity_monitor.Fclk_PD_Data_error_rate_coeff = input[9]; break; + default: + return -EINVAL; } result = vega20_set_activity_monitor_coeff(hwmgr, |