hrtimer: Cast explicitely to u32t in __ktime_divns()
authorWen Yang <wenyang@linux.alibaba.com>
Thu, 30 Jan 2020 13:08:51 +0000 (21:08 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 4 Mar 2020 09:17:51 +0000 (10:17 +0100)
do_div() does a 64-by-32 division at least on 32bit platforms, while the
divisor 'div' is explicitly casted to unsigned long, thus 64-bit on 64-bit
platforms.

The code already ensures that the divisor is less than 2^32. Hence the
proper cast type is u32.

Signed-off-by: Wen Yang <wenyang@linux.alibaba.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20200130130851.29204-1-wenyang@linux.alibaba.com
kernel/time/hrtimer.c

index 3a609e7344f3d9106d93b6eb53e1138fcf48581d..d74fdcd3ced4c611204a5d0bb8530b75ffa979fc 100644 (file)
@@ -311,7 +311,7 @@ s64 __ktime_divns(const ktime_t kt, s64 div)
                div >>= 1;
        }
        tmp >>= sft;
-       do_div(tmp, (unsigned long) div);
+       do_div(tmp, (u32) div);
        return dclc < 0 ? -tmp : tmp;
 }
 EXPORT_SYMBOL_GPL(__ktime_divns);