From: Axel Haslam Date: Wed, 5 Oct 2011 21:04:57 +0000 (-0700) Subject: cpufreq: interactive: fix possible Division by zero. X-Git-Tag: firefly_0821_release~7613^2~277 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3c053e150be20d335725ccd7384643fc8a3eb888;p=firefly-linux-kernel-4.4.55.git cpufreq: interactive: fix possible Division by zero. The following dump was seen sometimes while resuming, the only division by zero on this function can happen after delta_time is reassigned, since at the start of the function, there is jump that protects against values less than 1000. After that, If delta_time and delta_idle == 0, we will hit a div 0 Division by zero in kernel. Backtrace: [] (dump_backtrace+0x0/0x110) from [] (dump_stack+0x18/0x1c) r6:010f3000 r5:c113dfb0 r4:c004afb0 r3:c6ff0000 [] (dump_stack+0x0/0x1c) from [] (__div0+0x1c/0x20) [] (__div0+0x0/0x20) from [] (Ldiv0+0x8/0x10) [] (cpufreq_interactive_timer+0x0/0x2c0) from [] (run_timer_softirq+0x154/0x260) [] (run_timer_softirq+0x0/0x260) from [] (__do_softirq+0xc8/0x194) [] (__do_softirq+0x0/0x194) from [] (irq_exit+0xb4/0xb8) [] (irq_exit+0x0/0xb8) from [] (ipi_timer+0x44/0x48) r4:c004a040 r3:00000001 [] (ipi_timer+0x0/0x48) from [] (do_local_timer+0x68/0x84) r5:c004ae2c r4:c07991e8 [] (do_local_timer+0x0/0x84) from [] (__irq_svc+0x48/0xe0) Change-Id: I639882db67b8d711c5710778ebc212f0f6a998e3 Acked-by: Nishanth Menon Signed-off-by: Axel Haslam --- diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c index d8f62f402bf2..d60cb380add1 100644 --- a/drivers/cpufreq/cpufreq_interactive.c +++ b/drivers/cpufreq/cpufreq_interactive.c @@ -145,7 +145,7 @@ static void cpufreq_interactive_timer(unsigned long data) delta_time = (unsigned int) cputime64_sub(pcpu->timer_run_time, pcpu->freq_change_time); - if (delta_idle > delta_time) + if ((delta_time == 0) || (delta_idle > delta_time)) load_since_change = 0; else load_since_change =