diff options
author | Kiran Patil <kiran.patil@intel.com> | 2019-02-26 19:35:10 -0500 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2019-03-22 11:19:17 -0400 |
commit | 60dcc39ea338dbc9d33dad8f788320950f85e0f3 (patch) | |
tree | 172f72febcacf500b71193c9383f5c878360f126 /drivers/net/ethernet/intel/ice/ice_lib.c | |
parent | 5743020d37d7e92c24c0a5d506989bdfacfddde4 (diff) |
ice: fix the divide by zero issue
Static analysis flagged a potential divide by zero error because
vsi->num_rxq can become zero in certain condition and it is used as
divisor.
Signed-off-by: Kiran Patil <kiran.patil@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/ice/ice_lib.c')
-rw-r--r-- | drivers/net/ethernet/intel/ice/ice_lib.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c index a602bd329cfa..5d364b79eb4d 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c | |||
@@ -881,7 +881,18 @@ static void ice_vsi_setup_q_map(struct ice_vsi *vsi, struct ice_vsi_ctx *ctxt) | |||
881 | tx_count += tx_numq_tc; | 881 | tx_count += tx_numq_tc; |
882 | ctxt->info.tc_mapping[i] = cpu_to_le16(qmap); | 882 | ctxt->info.tc_mapping[i] = cpu_to_le16(qmap); |
883 | } | 883 | } |
884 | vsi->num_rxq = offset; | 884 | |
885 | /* if offset is non-zero, means it is calculated correctly based on | ||
886 | * enabled TCs for a given VSI otherwise qcount_rx will always | ||
887 | * be correct and non-zero because it is based off - VSI's | ||
888 | * allocated Rx queues which is at least 1 (hence qcount_tx will be | ||
889 | * at least 1) | ||
890 | */ | ||
891 | if (offset) | ||
892 | vsi->num_rxq = offset; | ||
893 | else | ||
894 | vsi->num_rxq = qcount_rx; | ||
895 | |||
885 | vsi->num_txq = tx_count; | 896 | vsi->num_txq = tx_count; |
886 | 897 | ||
887 | if (vsi->type == ICE_VSI_VF && vsi->num_txq != vsi->num_rxq) { | 898 | if (vsi->type == ICE_VSI_VF && vsi->num_txq != vsi->num_rxq) { |