diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index 071e093c448670024d3804a7b8e03c4eff2eb68f..c0875ae0de1791239fdc6fadcc1a7f6c8ab09729 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -286,6 +286,10 @@ ktime_t ktime_add_ns(const ktime_t kt, u64 nsec) } else { unsigned long rem = do_div(nsec, NSEC_PER_SEC); + /* Make sure nsec fits into long */ + if (unlikely(nsec > KTIME_SEC_MAX)) + return (ktime_t){ .tv64 = KTIME_MAX }; + tmp = ktime_set((long)nsec, rem); }