DragonFlyBSD Kernel Audit
DF-1386 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/drm/radeon/cypress_dpm.c b/sys/dev/drm/radeon/cypress_dpm.c
--- a/sys/dev/drm/radeon/cypress_dpm.c
+++ b/sys/dev/drm/radeon/cypress_dpm.c
@@ -909,8 +909,14 @@
 {
 	struct rv7xx_power_info *pi = rv770_get_pi(rdev);
 	u32 multiplier = pi->mem_gddr5 ? 1 : 2;
-	u32 result = (4 * multiplier * engine_clock) / (memory_clock / 2);
-	u32 burst_time;
+	u32 result, burst_time;
+
+	/* memory_clock comes from the VBIOS power table. A 0 or 1 makes
+	 * memory_clock/2 == 0 and the division raises #DE -> panic. */
+	if (memory_clock == 0 || memory_clock == 1)
+		return 0;
+
+	result = (4 * multiplier * engine_clock) / (memory_clock / 2);
 
 	if (result <= 4)
 		burst_time = 0;