DragonFlyBSD Kernel Audit
DF-1392 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/drm/radeon/rv6xx_dpm.c b/sys/dev/drm/radeon/rv6xx_dpm.c
--- a/sys/dev/drm/radeon/rv6xx_dpm.c
+++ b/sys/dev/drm/radeon/rv6xx_dpm.c
@@ -543,6 +543,8 @@
 
 static inline u32 rv6xx_calculate_spread_spectrum_clk_s(u32 ss_rate, u32 ref_freq)
 {
+	if (ss_rate == 0)
+		return 0;
 	return (((ref_freq * 10) / (ss_rate * 2)) - 1) / 4;
 }
 
@@ -806,6 +808,11 @@
 		high_clock =
 			pi->hw.sclks[R600_POWER_LEVEL_LOW] * 0xFF / 0x40;
 
+	if (pi->hw.sclks[R600_POWER_LEVEL_LOW] == 0 ||
+	    pi->hw.sclks[R600_POWER_LEVEL_MEDIUM] == 0 ||
+	    pi->hw.sclks[R600_POWER_LEVEL_HIGH] == 0)
+		return;
+
 	radeon_atom_set_engine_dram_timings(rdev, high_clock, 0);
 
 	sqm_ratio = (STATE0(64 * high_clock / pi->hw.sclks[R600_POWER_LEVEL_LOW]) |