Commit 677f423c authored by Maciej W. Rozycki's avatar Maciej W. Rozycki Committed by Greg Kroah-Hartman
Browse files

rtc: hctosys: Add missing range error reporting

commit 7ce9a992


Fix an issue with the 32-bit range error path in `rtc_hctosys' where no
error code is set and consequently the successful preceding call result
from `rtc_read_time' is propagated to `rtc_hctosys_ret'.  This in turn
makes any subsequent call to `hctosys_show' incorrectly report in sysfs
that the system time has been set from this RTC while it has not.

Set the error to ERANGE then if we can't express the result due to an
Signed-off-by: default avatarMaciej W. Rozycki <>
Fixes: b3a5ac42

 ("rtc: hctosys: Ensure system time doesn't overflow time_t")
Cc: # 4.17+
Signed-off-by: default avatarAlexandre Belloni <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 6d1c38aa
......@@ -50,8 +50,10 @@ static int __init rtc_hctosys(void)
tv64.tv_sec = rtc_tm_to_time64(&tm);
#if BITS_PER_LONG == 32
if (tv64.tv_sec > INT_MAX)
if (tv64.tv_sec > INT_MAX) {
err = -ERANGE;
goto err_read;
err = do_settimeofday64(&tv64);
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