]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
clocksource: Fix abs() usage w/ 64bit values
authorJohn Stultz <john.stultz@linaro.org>
Tue, 15 Sep 2015 01:05:20 +0000 (18:05 -0700)
committerZefan Li <lizefan@huawei.com>
Wed, 27 Apr 2016 10:55:25 +0000 (18:55 +0800)
commit 67dfae0cd72fec5cd158b6e5fb1647b7dbe0834c upstream.

This patch fixes one cases where abs() was being used with 64-bit
nanosecond values, where the result may be capped at 32-bits.

This potentially could cause watchdog false negatives on 32-bit
systems, so this patch addresses the issue by using abs64().

Signed-off-by: John Stultz <john.stultz@linaro.org>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1442279124-7309-2-git-send-email-john.stultz@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
[lizf: Backported to 3.4: adjust context]
Signed-off-by: Zefan Li <lizefan@huawei.com>
kernel/time/clocksource.c

index c9583382141a439ce10980bfc399792e8c6f8423..b3f54079287d279a1d1ca5385f944da3c970cdb1 100644 (file)
@@ -291,7 +291,7 @@ static void clocksource_watchdog(unsigned long data)
                        continue;
 
                /* Check the deviation from the watchdog clocksource. */
-               if ((abs(cs_nsec - wd_nsec) > WATCHDOG_THRESHOLD)) {
+               if ((abs64(cs_nsec - wd_nsec) > WATCHDOG_THRESHOLD)) {
                        clocksource_unstable(cs, cs_nsec - wd_nsec);
                        continue;
                }