Skip to content
Commit 2776d232 authored by Colin Ian King's avatar Colin Ian King Committed by Jakub Kicinski
Browse files

net: dsa: fix unintended sign extension on a u16 left shift



The left shift of u16 variable high is promoted to the type int and
then sign extended to a 64 bit u64 value.  If the top bit of high is
set then the upper 32 bits of the result end up being set by the
sign extension. Fix this by explicitly casting the value in high to
a u64 before left shifting by 16 places.

Also, remove the initialisation of variable value to 0 at the start
of each loop iteration as the value is never read and hence the
assignment it is redundant.

Addresses-Coverity: ("Unintended sign extension")
Fixes: e4b27ebc ("net: dsa: Add DSA driver for Hirschmann Hellcreek switches")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Reviewed-by: default avatarKurt Kanzenbach <kurt@linutronix.de>
Link: https://lore.kernel.org/r/20201109124008.2079873-1-colin.king@canonical.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent e5a4b17d
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment