rtc: 88pm860x: fix unintended sign extension
authorColin Ian King <colin.king@canonical.com>
Wed, 6 Feb 2019 09:50:53 +0000 (09:50 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Jan 2020 09:24:14 +0000 (10:24 +0100)
commitdb00690fb71331218ff46ca0f02d3fcf0e4a8499
treea604acf81b3d9797f4bb09709c409524f18ce419
parentbd29fa39076f8640a546b84bc792765bda250a3a
rtc: 88pm860x: fix unintended sign extension

[ Upstream commit dc9e47160626cdb58d5c39a4f43dcfdb27a5c004 ]

Shifting a u8 by 24 will cause the value to be promoted to an integer. If
the top bit of the u8 is set then the following conversion to an unsigned
long will sign extend the value causing the upper 32 bits to be set in
the result.

Fix this by casting the u8 value to an unsigned long before the shift.

Detected by CoverityScan, CID#144925-144928 ("Unintended sign extension")

Fixes: 008b30408c40 ("mfd: Add rtc support to 88pm860x")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/rtc/rtc-88pm860x.c