DragonFlyBSD Kernel Audit
DF-1275 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/drm/amd/powerplay/smumgr/tonga_smumgr.c b/sys/dev/drm/amd/powerplay/smumgr/tonga_smumgr.c
--- a/sys/dev/drm/amd/powerplay/smumgr/tonga_smumgr.c
+++ b/sys/dev/drm/amd/powerplay/smumgr/tonga_smumgr.c
@@ -338,7 +338,7 @@
 	struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
 	uint32_t count;
 
-	table->VddciLevelCount = data->vddci_voltage_table.count;
+	table->VddciLevelCount = MIN(data->vddci_voltage_table.count, SMU72_MAX_LEVELS_VDDCI);
 	for (count = 0; count < table->VddciLevelCount; count++) {
 		if (SMU7_VOLTAGE_CONTROL_BY_SVID2 == data->vddci_control) {
 			table->VddciTable[count] =
@@ -422,7 +422,7 @@
 		/* We are populating vddgfx CAC data to BapmVddgfx table in split mode */
 		for (count = 0; count < vddgfx_level_count; count++) {
 			index = phm_get_voltage_index(vddgfx_lookup_table,
-				convert_to_vid(vddgfx_lookup_table->entries[index].us_cac_mid));
+				convert_to_vid(vddgfx_lookup_table->entries[count].us_cac_mid));
 			table->BapmVddGfxVidHiSidd2[count] =
 				convert_to_vid(vddgfx_lookup_table->entries[index].us_cac_high);
 		}