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>
Mon, 27 Jan 2020 13:50:20 +0000 (14:50 +0100)
commit4260a44a7d4e54faa974cb21d42e9ae752b52392
tree68b907984cfbddda14f9f6a50ec61383be46df8f
parent558dac2418b6d8001bc6c3416380a90b50773f57
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