]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 26 Mar 2019 02:28:56 +0000 (11:28 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 26 Mar 2019 02:28:56 +0000 (11:28 +0900)
added patches:
rtc-fix-overflow-when-converting-time64_t-to-rtc_time.patch

queue-4.4/rtc-fix-overflow-when-converting-time64_t-to-rtc_time.patch [new file with mode: 0644]
queue-4.4/series

diff --git a/queue-4.4/rtc-fix-overflow-when-converting-time64_t-to-rtc_time.patch b/queue-4.4/rtc-fix-overflow-when-converting-time64_t-to-rtc_time.patch
new file mode 100644 (file)
index 0000000..6b99e7c
--- /dev/null
@@ -0,0 +1,42 @@
+From 36d46cdb43efea74043e29e2a62b13e9aca31452 Mon Sep 17 00:00:00 2001
+From: Baolin Wang <baolin.wang@linaro.org>
+Date: Mon, 25 Dec 2017 19:10:37 +0800
+Subject: rtc: Fix overflow when converting time64_t to rtc_time
+
+From: Baolin Wang <baolin.wang@linaro.org>
+
+commit 36d46cdb43efea74043e29e2a62b13e9aca31452 upstream.
+
+If we convert one large time values to rtc_time, in the original formula
+'days * 86400' can be overflowed in 'unsigned int' type to make the formula
+get one incorrect remain seconds value. Thus we can use div_s64_rem()
+function to avoid this situation.
+
+Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
+Acked-by: Arnd Bergmann <arnd@arndb.de>
+Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/rtc/rtc-lib.c |    6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+--- a/drivers/rtc/rtc-lib.c
++++ b/drivers/rtc/rtc-lib.c
+@@ -52,13 +52,11 @@ EXPORT_SYMBOL(rtc_year_days);
+  */
+ void rtc_time64_to_tm(time64_t time, struct rtc_time *tm)
+ {
+-      unsigned int month, year;
+-      unsigned long secs;
++      unsigned int month, year, secs;
+       int days;
+       /* time must be positive */
+-      days = div_s64(time, 86400);
+-      secs = time - (unsigned int) days * 86400;
++      days = div_s64_rem(time, 86400, &secs);
+       /* day of the week, 1970-01-01 was a Thursday */
+       tm->tm_wday = (days + 4) % 7;
index 1e4d36ab9696c3e3421ef3604fdf2dba1df076c5..2fff9e94bf370e98fe812bba3739a3138a4aca2a 100644 (file)
@@ -33,3 +33,4 @@ usb-renesas_usbhs-gadget-fix-unused-but-set-variable-warning.patch
 serial-sprd-clear-timeout-interrupt-only-rather-than-all-interrupts.patch
 lib-int_sqrt-optimize-small-argument.patch
 usb-core-only-clean-up-what-we-allocated.patch
+rtc-fix-overflow-when-converting-time64_t-to-rtc_time.patch