]> git.proxmox.com Git - mirror_ubuntu-bionic-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)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 14 Aug 2018 10:29:55 +0000 (12:29 +0200)
commit974dbda834c1854549403955341b1331f34c648e
tree35d5d37d54e8af66dbacf388eb38e1cfe8ed7777
parentb606c20fce4260613169b68b865047b7412e6fd1
rtc: tx4939: avoid unintended sign extension on a 24 bit shift

BugLink: http://bugs.launchpad.net/bugs/1783418
[ Upstream commit 347876ad47b9923ce26e686173bbf46581802ffa ]

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: 0e1492330cd2 ("rtc: add rtc-tx4939 driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/rtc/rtc-tx4939.c