]> git.baikalelectronics.ru Git - kernel.git/commit
rtc: tx4939: avoid unintended sign extension on a 24 bit shift
authorColin Ian King <colin.king@canonical.com>
Thu, 15 Feb 2018 19:36:14 +0000 (19:36 +0000)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Thu, 1 Mar 2018 09:49:38 +0000 (10:49 +0100)
commitdc4eaa9a8cb0fa1398cb62eed96c43f1efbf4088
treeef1cf730fd20beae4fc7cf58805624a678f4df0e
parentf4011dca88396edb21022cf790923aa4705c3a65
rtc: tx4939: avoid unintended sign extension on a 24 bit shift

The shifting of buf[5] by 24 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 buf[5] is set then all then all the upper bits sec
end up as also being set because of the sign-extension. Fix this by
casting buf[5] to an unsigned long before the shift.

Detected by CoverityScan, CID#1465292 ("Unintended sign extension")

Fixes: 531460d8a11b ("rtc: add rtc-tx4939 driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-tx4939.c