Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d2dc13b5 authored by Wang Dongsheng's avatar Wang Dongsheng Committed by Scott Wood
Browse files

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: default avatarWang Dongsheng <dongsheng.wang@freescale.com>
Signed-off-by: default avatarScott Wood <scottwood@freescale.com>
parent 0fd79588
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -97,6 +97,9 @@ static void convert_ticks_to_time(struct timer_group_priv *priv,
	time->tv_sec = (__kernel_time_t)div_u64(ticks, priv->timerfreq);
	tmp_sec = (u64)time->tv_sec * (u64)priv->timerfreq;

	time->tv_usec = 0;

	if (tmp_sec <= ticks)
		time->tv_usec = (__kernel_suseconds_t)
			div_u64((ticks - tmp_sec) * 1000000, priv->timerfreq);