Skip to content

Commit 53c0352

Browse files
baruchsiachjohnstultz-work
authored andcommitted
sched_clock: Fix integer overflow
The expression '(1 << 32)' happens to evaluate as 0 on ARM, but it evaluates as 1 on xtensa and x86_64. This zeros sched_clock_mask, and breaks sched_clock(). Set the type of 1 to 'unsigned long long' to get the value we need. Reported-by: Max Filippov <jcmvbkbc@gmail.com> Tested-by: Max Filippov <jcmvbkbc@gmail.com> Acked-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: John Stultz <john.stultz@linaro.org>
1 parent b0ec636 commit 53c0352

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎kernel/time/sched_clock.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void __init setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate)
121121
BUG_ON(bits > 32);
122122
WARN_ON(!irqs_disabled());
123123
read_sched_clock = read;
124-
sched_clock_mask = (1 << bits) - 1;
124+
sched_clock_mask = (1ULL << bits) - 1;
125125
cd.rate = rate;
126126

127127
/* calculate the mult/shift to convert counter ticks to ns. */

0 commit comments

Comments
 (0)