rtc: 88pm860x: fix unintended sign extension
authorColin Ian King <colin.king@canonical.com>
Wed, 6 Feb 2019 09:50:53 +0000 (09:50 +0000)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Fri, 8 Feb 2019 08:30:13 +0000 (09:30 +0100)
commitdc9e47160626cdb58d5c39a4f43dcfdb27a5c004
tree92c28be37a213de3fb794fba6e2abe1a6ac88491
parent3f929cad943380370b6db31fcb7a38d898d91089
rtc: 88pm860x: fix unintended sign extension

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>
drivers/rtc/rtc-88pm860x.c