From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 3715F3230 for ; Fri, 23 Jun 2017 12:02:50 +0200 (CEST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jun 2017 03:02:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,377,1493708400"; d="scan'208";a="117965623" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga005.fm.intel.com with ESMTP; 23 Jun 2017 03:02:49 -0700 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 23 Jun 2017 03:02:48 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 23 Jun 2017 03:02:48 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.116]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.56]) with mapi id 14.03.0319.002; Fri, 23 Jun 2017 18:02:45 +0800 From: "Wu, Jingjing" To: "wang.yong19@zte.com.cn" CC: "dev@dpdk.org" , "Zhang, Helin" Thread-Topic: [PATCH] net/i40e: fix param check to avoid division by 0 Thread-Index: AQHS41zwi4X2F9+3dk6axHVUxqktuaItF2wg///O44CABWI6sA== Date: Fri, 23 Jun 2017 10:02:45 +0000 Message-ID: <9BB6961774997848B5B42BEC655768F810DADF7A@SHSMSX103.ccr.corp.intel.com> References: <1497258420-11814-1-git-send-email-wang.yong19@zte.com.cn> <9BB6961774997848B5B42BEC655768F810DAA643@SHSMSX103.ccr.corp.intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="iso-8859-1" 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: Fri, 23 Jun 2017 10:02:50 -0000 From: wang.yong19@zte.com.cn [mailto:wang.yong19@zte.com.cn]=20 Sent: Tuesday, June 20, 2017 3:48 PM To: Wu, Jingjing Cc: dev@dpdk.org; Zhang, Helin Subject: RE: [PATCH] net/i40e: fix param check to avoid division by 0 =A0 > RE: [PATCH] net/i40e: fix param check to avoid division by 0=20 >=20 >=20 >=20 > > -----Original Message----- > > From: Yong Wang [mailto:wang.yong19@zte.com.cn] > > Sent: Monday, June 12, 2017 5:07 PM > > To: Zhang, Helin ; Wu, Jingjing=20 > > > 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)". Fi= x > > it by adding a check to parameter 'enabled_tcmap'. > >=20 > > Signed-off-by: Yong Wang > > --- > > =A0drivers/net/i40e/i40e_ethdev.c | 5 +++++ > > =A01 file changed, 5 insertions(+) > >=20 > > diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_eth= dev.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 > > =A0 =A0 int i, total_tc =3D 0; > > =A0 =A0 uint16_t qpnum_per_tc, bsf, qp_idx; > >=20 > > + =A0 if (enabled_tcmap =3D=3D 0) { > > + =A0 =A0 =A0PMD_DRV_LOG(ERR, "Error! enabled tcmap shouldn't be 0"); > > + =A0 =A0 =A0return I40E_ERR_PARAM; > > + =A0 } > > + > > =A0 =A0 ret =3D validate_tcmap_parameter(vsi, enabled_tcmap); > > =A0 =A0 if (ret !=3D I40E_SUCCESS) > > =A0 =A0 =A0 =A0return ret; > > -- > Thanks for the fix. >=20 > Could you add the check in func validate_tcmap_parameter? >=20 > Thanks > Jingjing >=20 >=20 =A0Since func validate_tcmap_parameter() was called by 3 func, if I add=20 the check to func validate_tcmap_parameter(), I am not sure whether it=20 will impact the other two callers who didn't meet division by 0.=20 =A0 Or should I fix it by changing 'total_tc' from 0 to 1 just as func=20 i40e_vsi_update_queue_mapping() does?=20 Thanks, that would be better. Because other caller is used for default TC map, which is 1. Thanks Jingjing