From: Liav Rehana <li...@mellanox.com>

During the calculation of the nsec variable, "delta * tkr->mult" may cause
overflow to the msb, if the suspended time is too long.
In that case, we need to guarantee that the variable will not go through a
sign extension during its shift, and thus it will result in a much higher
value - close to the larget value of 64 bits.
The following commit fixes this problem, which causes the following bug:
Trying to connect through ftp to the os after a long enough suspended time
will cause the nsec variable to get a much higher value after its shift
because of sign extension, and thus the loop that follows some instructions
afterwards, implemented in the inline function __iter_div_u64_rem, will
take too long.

Signed-off-by: Liav Rehana <li...@mellanox.com>
---
 kernel/time/timekeeping.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 479d25c..ddf56a5 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -305,7 +305,7 @@ static inline s64 timekeeping_delta_to_ns(struct 
tk_read_base *tkr,
        s64 nsec;
 
        nsec = delta * tkr->mult + tkr->xtime_nsec;
-       nsec >>= tkr->shift;
+       nsec = ((u64) nsec) >> tkr->shift;
 
        /* If arch requires, add in get_arch_timeoffset() */
        return nsec + arch_gettimeoffset();
-- 
1.7.1

Reply via email to