diff --git a/sys/dev/drm/amd/amdgpu/kv_dpm.c b/sys/dev/drm/amd/amdgpu/kv_dpm.c --- a/sys/dev/drm/amd/amdgpu/kv_dpm.c +++ b/sys/dev/drm/amd/amdgpu/kv_dpm.c @@ -912,7 +912,7 @@ return 0; pi->uvd_level_count = 0; - for (i = 0; i < table->count; i++) { + for (i = 0; i < table->count && i < SMU7_MAX_LEVELS_UVD; i++) { if (pi->high_voltage_t && (pi->high_voltage_t < table->entries[i].v)) break; @@ -983,7 +983,7 @@ return 0; pi->vce_level_count = 0; - for (i = 0; i < table->count; i++) { + for (i = 0; i < table->count && i < SMU7_MAX_LEVELS_VCE; i++) { if (pi->high_voltage_t && pi->high_voltage_t < table->entries[i].v) break; @@ -1046,7 +1046,7 @@ return 0; pi->samu_level_count = 0; - for (i = 0; i < table->count; i++) { + for (i = 0; i < table->count && i < SMU7_MAX_LEVELS_SAMU; i++) { if (pi->high_voltage_t && pi->high_voltage_t < table->entries[i].v) break; @@ -1112,7 +1112,7 @@ return 0; pi->acp_level_count = 0; - for (i = 0; i < table->count; i++) { + for (i = 0; i < table->count && i < SMU7_MAX_LEVELS_ACP; i++) { pi->acp_level[i].Frequency = cpu_to_be32(table->entries[i].clk); pi->acp_level[i].MinVoltage = cpu_to_be16(table->entries[i].v); @@ -2423,7 +2423,7 @@ u32 vid_2bit; pi->graphics_dpm_level_count = 0; - for (i = 0; i < table->count; i++) { + for (i = 0; i < table->count && i < SMU7_MAX_LEVELS_GRAPHICS; i++) { if (pi->high_voltage_t && (pi->high_voltage_t < kv_convert_8bit_index_to_voltage(adev, table->entries[i].v))) @@ -2443,7 +2443,7 @@ &pi->sys_info.sclk_voltage_mapping_table; pi->graphics_dpm_level_count = 0; - for (i = 0; i < table->num_max_dpm_entries; i++) { + for (i = 0; i < table->num_max_dpm_entries && i < SMU7_MAX_LEVELS_GRAPHICS; i++) { if (pi->high_voltage_t && pi->high_voltage_t < kv_convert_2bit_index_to_voltage(adev, table->entries[i].vid_2bit))