Commit 53c035204253efe373d9ff166fae6147e8c693b6
Committed by
John Stultz
1 parent
b0ec636c93
Exists in
smarc-imx_3.14.28_1.0.0_ga
and in
1 other branch
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>
Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff
kernel/time/sched_clock.c
... | ... | @@ -121,7 +121,7 @@ |
121 | 121 | BUG_ON(bits > 32); |
122 | 122 | WARN_ON(!irqs_disabled()); |
123 | 123 | read_sched_clock = read; |
124 | - sched_clock_mask = (1 << bits) - 1; | |
124 | + sched_clock_mask = (1ULL << bits) - 1; | |
125 | 125 | cd.rate = rate; |
126 | 126 | |
127 | 127 | /* calculate the mult/shift to convert counter ticks to ns. */ |