]> git.baikalelectronics.ru Git - kernel.git/commit
octeontx2-pf: Fix unintentional sign extension issue
authorColin Ian King <colin.king@canonical.com>
Wed, 18 Nov 2020 13:05:20 +0000 (13:05 +0000)
committerJakub Kicinski <kuba@kernel.org>
Fri, 20 Nov 2020 19:05:16 +0000 (11:05 -0800)
commita6820505dda896bfe591448c4e42b25a8f8609c4
tree5613ec8fda5f6b1cb6b549b0401803934f94390c
parent6b9d9588e962bfda257ddd5b9efa14750dca3afd
octeontx2-pf: Fix unintentional sign extension issue

The shifting of the u16 result from ntohs(proto) by 16 bits to the
left will be promoted to a 32 bit signed int and then sign-extended
to a u64.  In the event that the top bit of the return from ntohs(proto)
is set then all then all the upper 32 bits of a 64 bit long end up as
also being set because of the sign-extension. Fix this by casting to
a u64 long before the shift.

Addresses-Coverity: ("Unintended sign extension")
Fixes: 7a78662ee2f3 ("octeontx2-pf: Add support for SR-IOV management function")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20201118130520.460365-1-colin.king@canonical.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c