From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out1.zte.com.cn (out1.zte.com.cn [202.103.147.172]) by dpdk.org (Postfix) with ESMTP id 535B3374 for ; Tue, 20 Jun 2017 09:49:09 +0200 (CEST) X-scanvirus: By SEG_CYREN AntiVirus Engine X-scanresult: CLEAN X-MAILFROM: X-RCPTTO: X-FROMIP: 10.30.3.20 X-SEG-Scaned: 1 X-Received: unknown,10.30.3.20,20170620153304 Received: from unknown (HELO mse01.zte.com.cn) (10.30.3.20) by localhost with (AES256-SHA encrypted) SMTP; 20 Jun 2017 07:33:04 -0000 Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id v5K7lubk007601; Tue, 20 Jun 2017 15:47:56 +0800 (GMT-8) (envelope-from wang.yong19@zte.com.cn) In-Reply-To: <9BB6961774997848B5B42BEC655768F810DAA643@SHSMSX103.ccr.corp.intel.com> References: <1497258420-11814-1-git-send-email-wang.yong19@zte.com.cn> <9BB6961774997848B5B42BEC655768F810DAA643@SHSMSX103.ccr.corp.intel.com> To: "Wu, Jingjing" Cc: "dev@dpdk.org" , "Zhang, Helin" MIME-Version: 1.0 X-KeepSent: 4BCC6D6D:E1B94798-48258145:00294D69; type=4; name=$KeepSent X-Mailer: Lotus Notes Release 8.5.3 September 15, 2011 Message-ID: From: wang.yong19@zte.com.cn Date: Tue, 20 Jun 2017 15:48:15 +0800 X-MIMETrack: Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-06-20 15:47:52, Serialize complete at 2017-06-20 15:47:52 X-MAIL: mse01.zte.com.cn v5K7lubk007601 X-HQIP: 127.0.0.1 Content-Type: text/plain; charset="US-ASCII" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 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 07:49:12 -0000 > RE: [PATCH] net/i40e: fix param check to avoid division by 0 > > > > > -----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 > > > > 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 adding a check to parameter 'enabled_tcmap'. > > > > Signed-off-by: Yong Wang > > --- > > drivers/net/i40e/i40e_ethdev.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.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 = 0; > > uint16_t qpnum_per_tc, bsf, qp_idx; > > > > + if (enabled_tcmap == 0) { > > + PMD_DRV_LOG(ERR, "Error! enabled tcmap shouldn't be 0"); > > + return I40E_ERR_PARAM; > > + } > > + > > ret = validate_tcmap_parameter(vsi, enabled_tcmap); > > if (ret != I40E_SUCCESS) > > return ret; > > -- > Thanks for the fix. > > Could you add the check in func validate_tcmap_parameter? > > Thanks > Jingjing > > Since func validate_tcmap_parameter() was called by 3 func, if I add the check to func validate_tcmap_parameter(), I am not sure whether it will impact the other two callers who didn't meet division by 0. Or should I fix it by changing 'total_tc' from 0 to 1 just as func i40e_vsi_update_queue_mapping() does? Thanks Yong