]> git.baikalelectronics.ru Git - kernel.git/commit
net: dsa: mv88e6xxx: avoid unintended sign extension on a 16 bit shift
authorColin Ian King <colin.king@canonical.com>
Fri, 16 Feb 2018 16:55:05 +0000 (16:55 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 16 Feb 2018 21:36:03 +0000 (16:36 -0500)
commitcec795f99cfcffe8e8a5e683dcfa6a6002cd5080
tree926aa48600bf8319af1fe4f2c9511ddcfda00910
parentbe3508e784df3e6e263489e359b0ef052042356e
net: dsa: mv88e6xxx: avoid unintended sign extension on a 16 bit shift

The shifting of timehi by 16 bits to the left will be promoted to
a 32 bit signed int and then sign-extended to an u64. If the top bit
of timehi is set then all then all the upper bits of ns end up as also
being set because of the sign-extension. Fix this by making timehi and
timelo u64.  Also move the declaration of ns.

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

Fixes: b85473802a8b ("net: dsa: mv88e6xxx: add rx/tx timestamping support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/mv88e6xxx/hwtstamp.c