Patch "rtc: mc146818-lib: fix locking in mc146818_set_time" has been added to the 5.10-stable tree

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

 



This is a note to let you know that I've just added the patch titled

    rtc: mc146818-lib: fix locking in mc146818_set_time

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     rtc-mc146818-lib-fix-locking-in-mc146818_set_time.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit a8d5f97b17590662e2bed1ee13cfed7ecb560720
Author: Mateusz Jończyk <mat.jonczyk@xxxxx>
Date:   Sun Feb 20 10:04:03 2022 +0100

    rtc: mc146818-lib: fix locking in mc146818_set_time
    
    [ Upstream commit 811f5559270f25c34c338d6eaa2ece2544c3d3bd ]
    
    In mc146818_set_time(), CMOS_READ(RTC_CONTROL) was performed without the
    rtc_lock taken, which is required for CMOS accesses. Fix this.
    
    Nothing in kernel modifies RTC_DM_BINARY, so a separate critical section
    is allowed here.
    
    Fixes: dcf257e92622 ("rtc: mc146818: Reduce spinlock section in mc146818_set_time()")
    Signed-off-by: Mateusz Jończyk <mat.jonczyk@xxxxx>
    Cc: Alessandro Zummo <a.zummo@xxxxxxxxxxxx>
    Cc: Alexandre Belloni <alexandre.belloni@xxxxxxxxxxx>
    Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
    Cc: stable@xxxxxxxxxxxxxxx
    Signed-off-by: Alexandre Belloni <alexandre.belloni@xxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20220220090403.153928-1-mat.jonczyk@xxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/rtc/rtc-mc146818-lib.c b/drivers/rtc/rtc-mc146818-lib.c
index 1ca866461d10..3783aaf9dd5a 100644
--- a/drivers/rtc/rtc-mc146818-lib.c
+++ b/drivers/rtc/rtc-mc146818-lib.c
@@ -283,8 +283,10 @@ int mc146818_set_time(struct rtc_time *time)
 	if (yrs >= 100)
 		yrs -= 100;
 
-	if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY)
-	    || RTC_ALWAYS_BCD) {
+	spin_lock_irqsave(&rtc_lock, flags);
+	save_control = CMOS_READ(RTC_CONTROL);
+	spin_unlock_irqrestore(&rtc_lock, flags);
+	if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
 		sec = bin2bcd(sec);
 		min = bin2bcd(min);
 		hrs = bin2bcd(hrs);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux