Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/mpic_timer: fix convert ticks to time subtraction overflow

In some cases tmp_sec may be greater than ticks, because in the process
of calculation ticks and tmp_sec will be rounded.

Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>

authored by

Wang Dongsheng and committed by
Scott Wood
d2dc13b5 0fd79588

+5 -2
+5 -2
arch/powerpc/sysdev/mpic_timer.c
··· 97 97 time->tv_sec = (__kernel_time_t)div_u64(ticks, priv->timerfreq); 98 98 tmp_sec = (u64)time->tv_sec * (u64)priv->timerfreq; 99 99 100 - time->tv_usec = (__kernel_suseconds_t) 101 - div_u64((ticks - tmp_sec) * 1000000, priv->timerfreq); 100 + time->tv_usec = 0; 101 + 102 + if (tmp_sec <= ticks) 103 + time->tv_usec = (__kernel_suseconds_t) 104 + div_u64((ticks - tmp_sec) * 1000000, priv->timerfreq); 102 105 103 106 return; 104 107 }