From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 270622C13 for ; Tue, 20 Jun 2017 04:44:50 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jun 2017 19:44:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,363,1493708400"; d="scan'208";a="1184596934" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga002.fm.intel.com with ESMTP; 19 Jun 2017 19:44:49 -0700 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 19 Jun 2017 19:44:49 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 19 Jun 2017 19:44:49 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.116]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0319.002; Tue, 20 Jun 2017 10:44:47 +0800 From: "Wu, Jingjing" To: Yong Wang , "Zhang, Helin" CC: "dev@dpdk.org" Thread-Topic: [PATCH] net/i40e: fix param check to avoid division by 0 Thread-Index: AQHS41zwi4X2F9+3dk6axHVUxqktuaItF2wg Date: Tue, 20 Jun 2017 02:44:46 +0000 Message-ID: <9BB6961774997848B5B42BEC655768F810DAA643@SHSMSX103.ccr.corp.intel.com> References: <1497258420-11814-1-git-send-email-wang.yong19@zte.com.cn> In-Reply-To: <1497258420-11814-1-git-send-email-wang.yong19@zte.com.cn> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix param check to avoid division by 0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jun 2017 02:44:51 -0000 > -----Original Message----- > From: Yong Wang [mailto:wang.yong19@zte.com.cn] > Sent: Monday, June 12, 2017 5:07 PM > To: Zhang, Helin ; Wu, Jingjing > Cc: dev@dpdk.org; Yong Wang > Subject: [PATCH] net/i40e: fix param check to avoid division by 0 >=20 > 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 =3D i40e_align_floor(vsi->nb_qps / total_tc)". Fix > it by adding a check to parameter 'enabled_tcmap'. >=20 > Signed-off-by: Yong Wang > --- > drivers/net/i40e/i40e_ethdev.c | 5 +++++ > 1 file changed, 5 insertions(+) >=20 > diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethde= v.c > index c18a93b..d41b213 100644 > --- a/drivers/net/i40e/i40e_ethdev.c > +++ b/drivers/net/i40e/i40e_ethdev.c > @@ -4257,6 +4257,11 @@ enum i40e_status_code > int i, total_tc =3D 0; > uint16_t qpnum_per_tc, bsf, qp_idx; >=20 > + if (enabled_tcmap =3D=3D 0) { > + PMD_DRV_LOG(ERR, "Error! enabled tcmap shouldn't be 0"); > + return I40E_ERR_PARAM; > + } > + > ret =3D validate_tcmap_parameter(vsi, enabled_tcmap); > if (ret !=3D I40E_SUCCESS) > return ret; > -- Thanks for the fix. Could you add the check in func validate_tcmap_parameter? Thanks Jingjing