[dpdk-dev] [PATCH] net/i40e: fix param check to avoid division by 0

Wu, Jingjing jingjing.wu at intel.com
Tue Jun 20 04:44:46 CEST 2017



> -----Original Message-----
> From: Yong Wang [mailto:wang.yong19 at zte.com.cn]
> Sent: Monday, June 12, 2017 5:07 PM
> To: Zhang, Helin <helin.zhang at intel.com>; Wu, Jingjing <jingjing.wu at intel.com>
> Cc: dev at dpdk.org; Yong Wang <wang.yong19 at zte.com.cn>
> 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 <wang.yong19 at zte.com.cn>
> ---
>  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



More information about the dev mailing list