aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/time64.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/time64.h')
-rw-r--r--include/linux/time64.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/time64.h b/include/linux/time64.h
index ad33260618f7..99ab4a686c30 100644
--- a/include/linux/time64.h
+++ b/include/linux/time64.h
@@ -189,6 +189,10 @@ static inline bool timespec64_valid_strict(const struct timespec64 *ts)
*/
static inline s64 timespec64_to_ns(const struct timespec64 *ts)
{
+ /* Prevent multiplication overflow */
+ if ((unsigned long long)ts->tv_sec >= KTIME_SEC_MAX)
+ return KTIME_MAX;
+
return ((s64) ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec;
}