From: ben-linux@fluff.org (Ben Dooks)
To: linus-amlogic@lists.infradead.org
Subject: [PATCH 5/5] rtc: warn if rtc_tm_to_time64 overflows in rtc_tm_to_time
Date: Mon, 22 Aug 2016 23:15:01 +0100 [thread overview]
Message-ID: <20160822221501.21945-6-ben-linux@fluff.org> (raw)
In-Reply-To: <20160822221501.21945-1-ben-linux@fluff.org>
The addition of the compatibility layer for rtc_tm_to_time()
to bridge the move to rtc_tm_to_time64() does not check if
the value will overflow the old call's use of unsigned long
to restore the result.
This means that if the result is bigger than the arch's
use of unsigned long then the result will be silently
truncated to whatever the maximum value of the unsigned
long. Since the call does not have an option of returning
an error, at least have an WARN_ON() to show if the value
is out of range.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
---
include/linux/rtc.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index b693ada..ef7bb2c 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -45,7 +45,10 @@ static inline void rtc_time_to_tm(unsigned long time, struct rtc_time *tm)
*/
static inline int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time)
{
- *time = rtc_tm_to_time64(tm);
+ time64_t tt = rtc_tm_to_time64(tm);
+
+ WARN_ON(tt > ~(0UL));
+ *time = tt;
return 0;
}
--
2.9.3
next prev parent reply other threads:[~2016-08-22 22:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-22 22:14 RFC: RTC v5 Ben Dooks
2016-08-22 22:14 ` [PATCH 1/5] rtc: support for amlogic meson rtc Ben Dooks
2016-08-22 22:14 ` [PATCH 2/5] ARM: dts: amlogic: add rtc node for meson8b Ben Dooks
2016-08-22 22:14 ` [PATCH 3/5] meson-rtc: add device-tree binding Ben Dooks
2016-08-22 22:15 ` [PATCH 4/5] ARM: meson: enable RTC for ODRoid-C1 Ben Dooks
2016-08-22 22:15 ` Ben Dooks [this message]
2016-09-07 21:06 ` RFC: RTC v5 Kevin Hilman
2016-09-08 10:21 ` Ben Dooks
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160822221501.21945-6-ben-linux@fluff.org \
--to=ben-linux@fluff.org \
--cc=linus-amlogic@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.