]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
liquidio: Fix unintentional sign extension issue on left shift of u16
authorColin Ian King <colin.king@canonical.com>
Wed, 14 Jul 2021 15:23:43 +0000 (16:23 +0100)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Mon, 20 Sep 2021 16:49:29 +0000 (18:49 +0200)
commit09c258af2db2b6820ff0657a2b2d803752b25a12
tree1b1d1f0616c60c4c7628a31c9698dbf82b86a436
parent93c1a3841ff7dfbf688373dd8304bc50edb4c63c
liquidio: Fix unintentional sign extension issue on left shift of u16

BugLink: https://bugs.launchpad.net/bugs/1939899
[ Upstream commit e7efc2ce3d0789cd7c21b70ff00cd7838d382639 ]

Shifting the u16 integer oct->pcie_port by CN23XX_PKT_INPUT_CTL_MAC_NUM_POS
(29) bits will be promoted to a 32 bit signed int and then sign-extended
to a u64. In the cases where oct->pcie_port where bit 2 is set (e.g. 3..7)
the shifted value will be sign extended and the top 32 bits of the result
will be set.

Fix this by casting the u16 values to a u64 before the 29 bit left shift.

Addresses-Coverity: ("Unintended sign extension")

Fixes: 3451b97cce2d ("liquidio: CN23XX register setup")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c