From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yong Wang Subject: [PATCH v2] net/i40e: fix division by 0 error Date: Fri, 23 Jun 2017 06:57:47 -0400 Message-ID: <1498215467-19681-1-git-send-email-wang.yong19@zte.com.cn> Cc: dev@dpdk.org, Yong Wang To: jingjing.wu@intel.com Return-path: Received: from out1.zte.com.cn (out1.zte.com.cn [202.103.147.172]) by dpdk.org (Postfix) with ESMTP id 07C6D2BF1 for ; Fri, 23 Jun 2017 13:07:13 +0200 (CEST) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In function i40e_vsi_config_tc_queue_mapping(), if 'enabled_tcmap' is 0, 'total_tc' might be 0. Then 'total_tc' might be used in a division by 0 in "qpnum_per_tc = i40e_align_floor(vsi->nb_qps / total_tc)". Fix it by changing 'total_tc' from 0 to 1 just as func i40e_vsi_update_queue_mapping() does. Signed-off-by: Yong Wang --- drivers/net/i40e/i40e_ethdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 4ee1113..0f54d09 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -4281,9 +4281,12 @@ enum i40e_status_code if (ret != I40E_SUCCESS) return ret; - for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) + for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { if (enabled_tcmap & (1 << i)) total_tc++; + } + if (total_tc == 0) + total_tc = 1; vsi->enabled_tc = enabled_tcmap; /* Number of queues per enabled TC */ -- 1.8.3.1