All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtc : Restricting year setting between 2000 to 2099 in rtc-s35390a driver
@ 2019-09-04 11:20 Sonawane, Aashish P
  2019-09-04 11:57 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Sonawane, Aashish P @ 2019-09-04 11:20 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni; +Cc: stable, Saitwal, Meghan


S-35390A RTC chip allows to set the lower two digit of the Western calendar year (00 to 99) and links together with the auto calendar from the year 2000 to the year 2099. If we try to set year earlier than 2000 then hardware clock get reset to "epoch". This patch check for year value between 2000 to 2099 otherwise returns "EINVAL" error. In conclusion this patch restricts system to set hardware clock to set year below and above the year 2000 and 2099 respectively.

Signed-off-by: Aashish P Sonawane mailto:AashishPSonawane@eaton.com
Suggested-by: Meghan Saitwal mailto:MeghanSaitwal@eaton.com
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
index 84806ff763cf..aea52548571e 100644
--- a/drivers/rtc/rtc-s35390a.c
+++ b/drivers/rtc/rtc-s35390a.c
@@ -214,6 +214,9 @@ static int s35390a_rtc_set_time(struct device *dev, struct rtc_time *tm)
 	int i, err;
 	char buf[7], status;
 
+	if (tm->tm_year < 100 || tm->tm_year > 199)
+		return EINVAL;
+
 	dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d mday=%d, "
 		"mon=%d, year=%d, wday=%d\n", __func__, tm->tm_sec,
 		tm->tm_min, tm->tm_hour, tm->tm_mday, tm->tm_mon, tm->tm_year,

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] rtc : Restricting year setting between 2000 to 2099 in rtc-s35390a driver
  2019-09-04 11:20 [PATCH] rtc : Restricting year setting between 2000 to 2099 in rtc-s35390a driver Sonawane, Aashish P
@ 2019-09-04 11:57 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2019-09-04 11:57 UTC (permalink / raw)
  To: Sonawane, Aashish P; +Cc: a.zummo, alexandre.belloni, stable, Saitwal, Meghan

On Wed, Sep 04, 2019 at 11:20:26AM +0000, Sonawane, Aashish P wrote:
> 
> S-35390A RTC chip allows to set the lower two digit of the Western calendar year (00 to 99) and links together with the auto calendar from the year 2000 to the year 2099. If we try to set year earlier than 2000 then hardware clock get reset to "epoch". This patch check for year value between 2000 to 2099 otherwise returns "EINVAL" error. In conclusion this patch restricts system to set hardware clock to set year below and above the year 2000 and 2099 respectively.
> 
> Signed-off-by: Aashish P Sonawane mailto:AashishPSonawane@eaton.com
> Suggested-by: Meghan Saitwal mailto:MeghanSaitwal@eaton.com
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
> index 84806ff763cf..aea52548571e 100644
> --- a/drivers/rtc/rtc-s35390a.c
> +++ b/drivers/rtc/rtc-s35390a.c
> @@ -214,6 +214,9 @@ static int s35390a_rtc_set_time(struct device *dev, struct rtc_time *tm)
>  	int i, err;
>  	char buf[7], status;
>  
> +	if (tm->tm_year < 100 || tm->tm_year > 199)
> +		return EINVAL;
> +
>  	dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d mday=%d, "
>  		"mon=%d, year=%d, wday=%d\n", __func__, tm->tm_sec,
>  		tm->tm_min, tm->tm_hour, tm->tm_mday, tm->tm_mon, tm->tm_year,

<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-09-04 11:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-04 11:20 [PATCH] rtc : Restricting year setting between 2000 to 2099 in rtc-s35390a driver Sonawane, Aashish P
2019-09-04 11:57 ` Greg KH

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.