Re: [PATCH] rtc : Restricting year setting between 2000 to 2099 in rtc-s35390a driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx
> Suggested-by: Meghan Saitwal mailto:MeghanSaitwal@xxxxxxxxx
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------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>



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux