rtc: mc146818-lib: fix locking in mc146818_set_time
authorMateusz Jończyk <mat.jonczyk@o2.pl>
Sun, 20 Feb 2022 09:04:03 +0000 (10:04 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Dec 2022 10:31:59 +0000 (11:31 +0100)
commit5c432383b6870c4c6e45ff9b02d89c39013f2e9b
treea8f1bcb9e4cd6979ed57aec8ee03e2b20ca81267
parent5e26531d8113da79dbc03b92d84ea47fa87683af
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@o2.pl>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20220220090403.153928-1-mat.jonczyk@o2.pl
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/rtc/rtc-mc146818-lib.c