]> git.baikalelectronics.ru Git - kernel.git/commit
rtc: cmos: zero-init wkalrm when reading from CMOS
authorVictor Ding <victording@google.com>
Fri, 14 Aug 2020 09:17:30 +0000 (19:17 +1000)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Thu, 20 Aug 2020 22:10:33 +0000 (00:10 +0200)
commitfa3eded2bb06fbe1dd25cab4eaf86e9b8e9b6dd4
tree7f0529705333f96e197e6f23da322bc751f2af26
parente5f0bf958198ed018c9fdf06e8d307ced9af9c95
rtc: cmos: zero-init wkalrm when reading from CMOS

cmos_read_alarm() may leave certain fields of a struct rtc_wkalrm
untouched; therefore, these fields contain garbage if not properly
initialized, leading to inconsistent values when converting into
time64_t. This patch to zero initialize the struct before calling
cmos_read_alarm().

Note that this patch is not intended to produce a correct time64_t, it
is only to produce a consistent value. In the case of suspend/resume, a
correct time64_t is not necessary; a consistent value is sufficient to
correctly perform an equality test for t_current_expires and
t_saved_expires. Logic to deduce a correct time64_t is expensive and
hence should be avoided.

Signed-off-by: Victor Ding <victording@google.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200814191654.v2.1.Iaf7638a2f2a87ff68d85fcb8dec615e41340c97f@changeid
drivers/rtc/rtc-cmos.c