[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <A7F79952C173F44692D7CBEC7DD540090EAA28D2@ORSMSX104.amr.corp.intel.com>
Date: Wed, 5 Oct 2016 17:32:25 +0000
From: "Kim, Andrew" <andrew.kim@...el.com>
To: Geert Uytterhoeven <geert@...ux-m68k.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH 1/1] rtc: add century field data boundary
Thanks for the comments, let me follow this.
BRs
Andrew
-----Original Message-----
From: geert.uytterhoeven@...il.com [mailto:geert.uytterhoeven@...il.com] On Behalf Of Geert Uytterhoeven
Sent: Wednesday, October 05, 2016 12:03 AM
To: Kim, Andrew
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] rtc: add century field data boundary
On Tue, Oct 4, 2016 at 8:06 PM, Andrew Kim <andrew.kim@...el.com> wrote:
> 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@...el.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)
Please don't combine assignments and comparisons into a single statement (especially for non-NULL comparisons), i.e. use
century = CMOS_READ(acpi_gbl_FADT.century);
if (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)
Likewise
> + century = 0;
> + }
> #endif
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Powered by blists - more mailing lists