diff options
author | Colin Ian King <colin.king@canonical.com> | 2021-06-05 14:20:59 +0200 |
---|---|---|
committer | Jason Gunthorpe <jgg@nvidia.com> | 2021-06-08 01:19:03 +0200 |
commit | 7fde2dbe03f41fd9ce0f38ebf9879e02487e5bdc (patch) | |
tree | 15fdabc43ad3f21a5f194bbbee9e622a97ae9717 /drivers/infiniband/hw/irdma/ctrl.c | |
parent | RDMA/cxgb4: Fix missing error code in create_qp() (diff) | |
download | linux-7fde2dbe03f41fd9ce0f38ebf9879e02487e5bdc.tar.xz linux-7fde2dbe03f41fd9ce0f38ebf9879e02487e5bdc.zip |
RDMA/irdma: Fix issues with u8 left shift operation
The shifting of the u8 integer info->map[i] 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 u8 is set then all then all the upper 32 bits
of the u64 end up as also being set because of the sign-extension.
Fix this by casting the u8 values to a u64 before the left shift. This
Link: https://lore.kernel.org/r/20210605122059.25105-1-colin.king@canonical.com
Addresses-Coverity: ("Unitentional integer overflow / bad shift operation")
Fixes: 3f49d6842569 ("RDMA/irdma: Implement HW Admin Queue OPs")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Diffstat (limited to 'drivers/infiniband/hw/irdma/ctrl.c')
-rw-r--r-- | drivers/infiniband/hw/irdma/ctrl.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/irdma/ctrl.c b/drivers/infiniband/hw/irdma/ctrl.c index 5aa112067bce..8bd3aecadaf6 100644 --- a/drivers/infiniband/hw/irdma/ctrl.c +++ b/drivers/infiniband/hw/irdma/ctrl.c @@ -2157,7 +2157,7 @@ static enum irdma_status_code irdma_sc_set_up_map(struct irdma_sc_cqp *cqp, return IRDMA_ERR_RING_FULL; for (i = 0; i < IRDMA_MAX_USER_PRIORITY; i++) - temp |= info->map[i] << (i * 8); + temp |= (u64)info->map[i] << (i * 8); set_64bit_val(wqe, 0, temp); set_64bit_val(wqe, 40, |