summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorLihong Yang <lihong.yang@intel.com>2017-09-07 15:05:54 +0300
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2017-10-10 00:30:41 +0300
commitb861fb762a26144593387b84cd078ef86d99cf6f (patch)
treef64ff382da7c051baf779d8bc4cc5c985436b1de /drivers
parent6f853d4f8e93eeace504b021e05dfdbeb4d3b40f (diff)
downloadlinux-b861fb762a26144593387b84cd078ef86d99cf6f.tar.xz
i40e: add check for return from find_first_bit call
The find_first_bit function will return the size passed to search if the first set bit is not found. This patch adds the check in case that happens as the return value would be used as the index in an array and that would have caused the out-of-bounds access. Detected by CoverityScan, CID 1295969 Out-of-bounds access Signed-off-by: Lihong Yang <lihong.yang@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 83727906a386..125dcd1d2233 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -306,6 +306,10 @@ static void i40e_config_irq_link_list(struct i40e_vf *vf, u16 vsi_id,
next_q = find_first_bit(&linklistmap,
(I40E_MAX_VSI_QP *
I40E_VIRTCHNL_SUPPORTED_QTYPES));
+ if (unlikely(next_q == (I40E_MAX_VSI_QP *
+ I40E_VIRTCHNL_SUPPORTED_QTYPES)))
+ goto irq_list_done;
+
vsi_queue_id = next_q / I40E_VIRTCHNL_SUPPORTED_QTYPES;
qtype = next_q % I40E_VIRTCHNL_SUPPORTED_QTYPES;
pf_queue_id = i40e_vc_get_pf_queue_id(vf, vsi_id, vsi_queue_id);