From 6354f6714f8e25ed74f8879e938aa374c6a6216a Mon Sep 17 00:00:00 2001 From: ariff Date: Wed, 11 Jul 2007 14:27:45 +0000 Subject: [PATCH] Protect against divide by zero while calculating bus speed due to possible broken kernel timecounter. Reported/Tested by: silby Approved by: re (hrs) MFC after: 1 day --- sys/dev/sound/pci/ich.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/dev/sound/pci/ich.c b/sys/dev/sound/pci/ich.c index cebf0b6cf032..64e2eec38986 100644 --- a/sys/dev/sound/pci/ich.c +++ b/sys/dev/sound/pci/ich.c @@ -783,7 +783,11 @@ ich_calibrate(void *arg) return; } - actual_48k_rate = ((uint64_t)ch->blksz * 250000) / wait_us; + /* Just in case the timecounter screwed. It is possible, really. */ + if (wait_us > 0) + actual_48k_rate = ((uint64_t)ch->blksz * 250000) / wait_us; + else + actual_48k_rate = 48000; if (actual_48k_rate < 47500 || actual_48k_rate > 48500) { sc->ac97rate = actual_48k_rate;