DragonFlyBSD Kernel Audit
DF-1437 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/drm/radeon/sumo_dpm.c b/sys/dev/drm/radeon/sumo_dpm.c
--- a/sys/dev/drm/radeon/sumo_dpm.c
+++ b/sys/dev/drm/radeon/sumo_dpm.c
@@ -1620,6 +1620,11 @@ void sumo_construct_vid_mapping_table(struct radeon_device *rdev,
 	u32 i, j;
 
 	for (i = 0; i < SUMO_MAX_HARDWARE_POWERLEVELS; i++) {
+		/* DF-1437: usVoltageIndex is a u16 from the VBIOS sAvail_SCLK list
+		 * with no bound check. entries[] is fixed at SUMO_MAX_NUMBER_VOLTAGES
+		 * (4); skip out-of-range indices instead of overflowing. */
+		if (table[i].usVoltageIndex >= SUMO_MAX_NUMBER_VOLTAGES)
+			continue;
 		if (table[i].ulSupportedSCLK != 0) {
 			vid_mapping_table->entries[table[i].usVoltageIndex].vid_7bit =
 				table[i].usVoltageID;