RDMA/irdma: Fix potential overflow expression in irdma_prm_get_pbles
authorShiraz Saleem <shiraz.saleem@intel.com>
Fri, 25 Jun 2021 16:23:29 +0000 (11:23 -0500)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 25 Jun 2021 17:08:30 +0000 (14:08 -0300)
commit1f700757224effe598690b34e95329aff4e3e362
treebc3acf2b86ecadeeaad7d104b75cca4895174bae
parent46308965ae6fdc7c25deb2e8c048510ae51bbe66
RDMA/irdma: Fix potential overflow expression in irdma_prm_get_pbles

Coverity reports a signed 32-bit overflow on "1 << pprm->pble_shift" when
used expression to compute bits_needed that expects 64bit, unsigned.

Fix this by using the 1ULL in the left shift operator and convert mem_size
to u64.

Link: https://lore.kernel.org/r/20210625162329.1654-3-tatyana.e.nikolova@intel.com
Reported-by: coverity-bot <keescook+coverity-bot@chromium.org>
Addresses-Coverity-ID: 1505157 ("Integer handling issues")
Fixes: 915cc7ac0f8e ("RDMA/irdma: Add miscellaneous utility definitions")
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/irdma/pble.h
drivers/infiniband/hw/irdma/utils.c