diff --git a/include/linux/time64.h b/include/linux/time64.h index b58142aa0b1dd7f4d76e96e532e6b0d4bf31f1c8..e58f59674ad6dbac2b0a26b4323d3e5098726aba 100644 --- a/include/linux/time64.h +++ b/include/linux/time64.h @@ -62,6 +62,8 @@ static inline int timespec64_equal(const struct timespec64 *a, * lhs < rhs: return <0 * lhs == rhs: return 0 * lhs > rhs: return >0 + * + * Note: Both lhs and rhs must be normalized. */ static inline int timespec64_compare(const struct timespec64 *lhs, const struct timespec64 *rhs) { diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 64aa492f79422ec5c4f5641e6bbd63d031b9073f..17ba0a2f5f5d1918c818f2e328fcc86d0143a9f6 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1236,8 +1236,7 @@ int do_settimeofday64(const struct timespec64 *ts) timekeeping_forward_now(tk); xt = tk_xtime(tk); - ts_delta.tv_sec = ts->tv_sec - xt.tv_sec; - ts_delta.tv_nsec = ts->tv_nsec - xt.tv_nsec; + ts_delta = timespec64_sub(*ts, xt); if (timespec64_compare(&tk->wall_to_monotonic, &ts_delta) > 0) { ret = -EINVAL;