DragonFlyBSD Kernel Audit
DF-1296 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/drm/amd/powerplay/smumgr/ci_smumgr.c b/sys/dev/drm/amd/powerplay/smumgr/ci_smumgr.c
--- a/sys/dev/drm/amd/powerplay/smumgr/ci_smumgr.c
+++ b/sys/dev/drm/amd/powerplay/smumgr/ci_smumgr.c
@@ -1522,7 +1522,8 @@
 	struct phm_uvd_clock_voltage_dependency_table *uvd_table =
 		hwmgr->dyn_state.uvd_clock_voltage_dependency_table;
 
-	table->UvdLevelCount = (uint8_t)(uvd_table->count);
+	table->UvdLevelCount = (uvd_table->count > SMU7_MAX_LEVELS_UVD) ?
+	    SMU7_MAX_LEVELS_UVD : (uint8_t)(uvd_table->count);
 
 	for (count = 0; count < table->UvdLevelCount; count++) {
 		table->UvdLevel[count].VclkFrequency =
@@ -1563,7 +1564,8 @@
 	struct phm_vce_clock_voltage_dependency_table *vce_table =
 				hwmgr->dyn_state.vce_clock_voltage_dependency_table;
 
-	table->VceLevelCount = (uint8_t)(vce_table->count);
+	table->VceLevelCount = (vce_table->count > SMU7_MAX_LEVELS_VCE) ?
+	    SMU7_MAX_LEVELS_VCE : (uint8_t)(vce_table->count);
 	table->VceBootLevel = 0;
 
 	for (count = 0; count < table->VceLevelCount; count++) {
@@ -1595,7 +1597,8 @@
 	struct phm_acp_clock_voltage_dependency_table *acp_table =
 				hwmgr->dyn_state.acp_clock_voltage_dependency_table;
 
-	table->AcpLevelCount = (uint8_t)(acp_table->count);
+	table->AcpLevelCount = (acp_table->count > SMU7_MAX_LEVELS_ACP) ?
+	    SMU7_MAX_LEVELS_ACP : (uint8_t)(acp_table->count);
 	table->AcpBootLevel = 0;
 
 	for (count = 0; count < table->AcpLevelCount; count++) {