rtc: pcf2127: fix bug when reading alarm registers
authorHugo Villeneuve <hvilleneuve@dimonoff.com>
Tue, 8 Feb 2022 16:29:07 +0000 (11:29 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 May 2022 07:57:23 +0000 (09:57 +0200)
commitfe9f2f3a68fce6ab3fcedc3a316152061d0cd577
treeb1350f51f70cacd6c3d8dad870198cf8e8db5617
parent25ddeb6be3d94a112958c000136751cbca57015b
rtc: pcf2127: fix bug when reading alarm registers

[ Upstream commit 73ce05302007eece23a6acb7dc124c92a2209087 ]

The first bug is that reading the 5 alarm registers results in a read
operation of 20 bytes. The reason is because the destination buffer is
defined as an array of "unsigned int", and we use the sizeof()
operator on this array to define the bulk read count.

The second bug is that the read value is invalid, because we are
indexing the destination buffer as integers (4 bytes), instead of
indexing it as u8.

Changing the destination buffer type to u8 fixes both problems.

Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20220208162908.3182581-1-hugo@hugovil.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/rtc/rtc-pcf2127.c