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

Configure Feed

Select the types of activity you want to include in your feed.

timekeeping: Prevent 32bit truncation in scale64_check_overflow()

While unlikely the divisor in scale64_check_overflow() could be >= 32bit in
scale64_check_overflow(). do_div() truncates the divisor to 32bit at least
on 32bit platforms.

Use div64_u64() instead to avoid the truncation to 32-bit.

[ tglx: Massaged changelog ]

Signed-off-by: Wen Yang <wenyang@linux.alibaba.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20200120100523.45656-1-wenyang@linux.alibaba.com

authored by

Wen Yang and committed by
Thomas Gleixner
4cbbc3a0 b95e31c0

+1 -2
+1 -2
kernel/time/timekeeping.c
··· 1005 1005 ((int)sizeof(u64)*8 - fls64(mult) < fls64(rem))) 1006 1006 return -EOVERFLOW; 1007 1007 tmp *= mult; 1008 - rem *= mult; 1009 1008 1010 - do_div(rem, div); 1009 + rem = div64_u64(rem * mult, div); 1011 1010 *base = tmp + rem; 1012 1011 return 0; 1013 1012 }