From 803a9b3efd550bcb8ca7a0c73a2ee385dd547397 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Wed, 10 Oct 2012 19:46:46 +0000 Subject: [PATCH] panic() with reasonable message instead of returning zero frequency causing division by zero later if event timer's minimal period is above one second. For now it is just a theoretical possibility. Found by: Clang Static Analyzer --- sys/kern/kern_clocksource.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_clocksource.c b/sys/kern/kern_clocksource.c index a73536f2dc38..05e47e050935 100644 --- a/sys/kern/kern_clocksource.c +++ b/sys/kern/kern_clocksource.c @@ -602,7 +602,8 @@ round_freq(struct eventtimer *et, int freq) freq = (et->et_frequency + div / 2) / div; } if (et->et_min_period.sec > 0) - freq = 0; + panic("Event timer \"%s\" doesn't support sub-second periods!", + et->et_name); else if (et->et_min_period.frac != 0) freq = min(freq, BT2FREQ(&et->et_min_period)); if (et->et_max_period.sec == 0 && et->et_max_period.frac != 0)