[tip:timers/urgent] sched_clock: Fix integer overflow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  53c035204253efe373d9ff166fae6147e8c693b6
Gitweb:     http://git.kernel.org/tip/53c035204253efe373d9ff166fae6147e8c693b6
Author:     Baruch Siach <baruch@xxxxxxxxxx>
AuthorDate: Wed, 17 Jul 2013 12:46:53 +0300
Committer:  John Stultz <john.stultz@xxxxxxxxxx>
CommitDate: Mon, 22 Jul 2013 16:24:22 -0700

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@xxxxxxxxx>
Tested-by: Max Filippov <jcmvbkbc@xxxxxxxxx>
Acked-by: Russell King <rmk+kernel@xxxxxxxxxxxxxxxx>
Signed-off-by: Baruch Siach <baruch@xxxxxxxxxx>
Signed-off-by: John Stultz <john.stultz@xxxxxxxxxx>
---
 kernel/time/sched_clock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
index a326f27..0b479a6 100644
--- a/kernel/time/sched_clock.c
+++ b/kernel/time/sched_clock.c
@@ -121,7 +121,7 @@ void __init setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate)
 	BUG_ON(bits > 32);
 	WARN_ON(!irqs_disabled());
 	read_sched_clock = read;
-	sched_clock_mask = (1 << bits) - 1;
+	sched_clock_mask = (1ULL << bits) - 1;
 	cd.rate = rate;
 
 	/* calculate the mult/shift to convert counter ticks to ns. */
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux