]> git.itanic.dy.fi Git - linux-stable/commit
rtc: hctosys: Add missing range error reporting
authorMaciej W. Rozycki <macro@linux-mips.org>
Mon, 5 Nov 2018 03:48:25 +0000 (03:48 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Nov 2018 08:22:10 +0000 (09:22 +0100)
commit693a06b52aaba50349265857b45b5b1ebc5f11d9
tree02d224ec1b2add6823f6a86a358865ca4a1f2066
parent651c5d16f3a90db286fb6d83a31eda29a2c07cda
rtc: hctosys: Add missing range error reporting

commit 7ce9a992ffde8ce93d5ae5767362a5c7389ae895 upstream.

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
overflow.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Fixes: b3a5ac42ab18 ("rtc: hctosys: Ensure system time doesn't overflow time_t")
Cc: stable@vger.kernel.org # 4.17+
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/rtc/hctosys.c