From: Andrew Kim <andrew.kim@intel.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH 1/1] rtc: add century field data boundary
Date: Tue, 4 Oct 2016 11:06:03 -0700 [thread overview]
Message-ID: <1475604363-51821-1-git-send-email-andrew.kim@intel.com> (raw)
According to ACPI specification, the century field data
should be ranged 0-63. so if it's over this range, it could
cause system RTC settings error including alarmwakeup settings.
So it's required to have this boundary for safe RTC init settings.
Signed-off-by: Andrew Kim <andrew.kim@intel.com>
---
arch/x86/kernel/rtc.c | 7 +++++--
drivers/rtc/rtc-mc146818-lib.c | 7 +++++--
include/linux/mc146818rtc.h | 2 ++
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
index 79c6311c..feac180 100644
--- a/arch/x86/kernel/rtc.c
+++ b/arch/x86/kernel/rtc.c
@@ -84,8 +84,11 @@ void mach_get_cmos_time(struct timespec *now)
#ifdef CONFIG_ACPI
if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID &&
- acpi_gbl_FADT.century)
- century = CMOS_READ(acpi_gbl_FADT.century);
+ acpi_gbl_FADT.century) {
+ if ((century = CMOS_READ(acpi_gbl_FADT.century)) >
+ RTC_CENTURY_LIMIT)
+ century = 0;
+ }
#endif
status = CMOS_READ(RTC_CONTROL);
diff --git a/drivers/rtc/rtc-mc146818-lib.c b/drivers/rtc/rtc-mc146818-lib.c
index 2f1772a..1d83c2c 100644
--- a/drivers/rtc/rtc-mc146818-lib.c
+++ b/drivers/rtc/rtc-mc146818-lib.c
@@ -61,8 +61,11 @@ unsigned int mc146818_get_time(struct rtc_time *time)
#endif
#ifdef CONFIG_ACPI
if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID &&
- acpi_gbl_FADT.century)
- century = CMOS_READ(acpi_gbl_FADT.century);
+ acpi_gbl_FADT.century) {
+ if ((century = CMOS_READ(acpi_gbl_FADT.century)) >
+ RTC_CENTURY_LIMIT)
+ century = 0;
+ }
#endif
ctrl = CMOS_READ(RTC_CONTROL);
spin_unlock_irqrestore(&rtc_lock, flags);
diff --git a/include/linux/mc146818rtc.h b/include/linux/mc146818rtc.h
index a585b4b..199065a 100644
--- a/include/linux/mc146818rtc.h
+++ b/include/linux/mc146818rtc.h
@@ -122,6 +122,8 @@ struct cmos_rtc_board_info {
#define RTC_IO_EXTENT_USED RTC_IO_EXTENT
#endif /* ARCH_RTC_LOCATION */
+#define RTC_CENTURY_LIMIT 0x3F
+
unsigned int mc146818_get_time(struct rtc_time *time);
int mc146818_set_time(struct rtc_time *time);
--
1.9.1
next reply other threads:[~2016-10-04 18:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-04 18:06 Andrew Kim [this message]
2016-10-05 7:03 ` Geert Uytterhoeven
2016-10-05 17:32 ` Kim, Andrew
2016-10-05 18:48 Andrew Kim
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=1475604363-51821-1-git-send-email-andrew.kim@intel.com \
--to=andrew.kim@intel.com \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®