drm/amd/pm: validate vega10 profile mode inputs

Check for out of range profile modes and custom params that exceed 8 bits.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Asad Kamal <asad.kamal@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Lijo Lazar
2026-06-18 10:56:54 +05:30
committed by Alex Deucher
parent 7445035dd3
commit bf939f2a16

View File

@@ -5215,6 +5215,11 @@ static int vega10_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, ui
uint8_t min_active_level;
uint32_t power_profile_mode = input[size];
if (power_profile_mode > PP_SMC_POWER_PROFILE_CUSTOM) {
pr_err("Invalid power profile mode %u\n", power_profile_mode);
return -EINVAL;
}
if (power_profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) {
if (size != 0 && size != 4)
return -EINVAL;
@@ -5230,6 +5235,10 @@ static int vega10_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, ui
return -EINVAL;
}
if ((input[0] & ~0xFF) || (input[1] & ~0xFF) ||
(input[2] & ~0xFF) || (input[3] & ~0xFF))
return -EINVAL;
data->custom_profile_mode[0] = busy_set_point = input[0];
data->custom_profile_mode[1] = FPS = input[1];
data->custom_profile_mode[2] = use_rlc_busy = input[2];