]> git.baikalelectronics.ru Git - kernel.git/commit
rtc: msc313: Fix unintentional sign extension issues with left shift of a u16
authorColin Ian King <colin.king@canonical.com>
Tue, 28 Sep 2021 13:46:54 +0000 (14:46 +0100)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Fri, 1 Oct 2021 21:28:46 +0000 (23:28 +0200)
commit5ed0fff3e54f861ff8e8df5f4b8311babaa9e347
treeb8d85f97457b4a32c252b7c17ad8ccf6be2302fb
parent5cc88fbe390599b625db6517149ca438ab2138d5
rtc: msc313: Fix unintentional sign extension issues with left shift of a u16

Shifting the u16 value returned by readw by 16 bits to the left
will be promoted to a 32 bit signed int and then sign-extended
to an unsigned long. If the top bit of the readw is set then
the shifted value will be sign extended and the top 32 bits of
the result will be set.

Fixes: 836b05f3d28e ("rtc: Add support for the MSTAR MSC313 RTC")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210928134654.991923-1-colin.king@canonical.com
drivers/rtc/rtc-msc313.c