Commit dfc2507b authored by John Stultz's avatar John Stultz Committed by Thomas Gleixner
Browse files

time: Make settimeofday error checking work again

In commit 86d34732 some of the checking for a valid timeval
was subtley changed which caused -EINVAL to be returned whenever
the timeval was null.

However, it is possible to set the timezone data while specifying
a NULL timeval, which is usually done to handle systems where the
RTC keeps local time instead of UTC. Thus the patch causes such
systems to have the time incorrectly set.

This patch addresses the issue by handling the error conditionals
in the same way as was done previously.

Fixes: 86d34732

 "time: Introduce do_sys_settimeofday64()"
Reported-by: default avatarMika Westerberg <>
Signed-off-by: default avatarJohn Stultz <>
Tested-by: default avatarMika Westerberg <>
Cc: Prarit Bhargava <>
Cc: Arnd Bergmann <>
Cc: Baolin Wang <>
Cc: Richard Cochran <>
Cc: Shuah Khan <>

Signed-off-by: default avatarThomas Gleixner <>
parent 1a695a90
......@@ -21,6 +21,9 @@ static inline int do_sys_settimeofday(const struct timespec *tv,
struct timespec64 ts64;
if (!tv)
return do_sys_settimeofday64(NULL, tz);
if (!timespec_valid(tv))
return -EINVAL;
ts64 = timespec_to_timespec64(*tv);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment