[dpdk-dev] [PATCH] raw/ifpga: fix unintentional integer overflow

Xu, Rosen rosen.xu at intel.com
Thu May 23 04:11:09 CEST 2019


Hi Andy,

Why you sent this patch two times?

> -----Original Message-----
> From: Pei, Andy
> Sent: Wednesday, May 22, 2019 14:43
> To: dev at dpdk.org
> Cc: Pei, Andy <andy.pei at intel.com>; Xu, Rosen <rosen.xu at intel.com>;
> stable at dpdk.org
> Subject: [PATCH] raw/ifpga: fix unintentional integer overflow
> 
> cast unsigned int ports_per_retimer, unsigned int nums_retimer, unsigned
> int nums_fvl and unsigned int ports_per_fvl to uint64_t before multiply
> operation, to avoid Unintentional integer overflow.
> 
> Coverity issue: 337924, 337926
> Fixes: d1cd4eb2d48e ("raw/ifpga: support ipn3ke")
> Cc: rosen.xu at intel.com
> Cc: stable at dpdk.org
> 
> Signed-off-by: Andy Pei <andy.pei at intel.com>
> ---
>  drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
> b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
> index 41be1a2..9c68666 100644
> --- a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
> +++ b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
> @@ -494,8 +494,8 @@
>  	if (!strcmp(attr_name, "LineSideLinkPortNum")) {
>  		if (opae_manager_get_retimer_info(mgr, &opae_rtm_info))
>  			return -1;
> -		uint64_t tmp = opae_rtm_info.ports_per_retimer *
> -			opae_rtm_info.nums_retimer;
> +		uint64_t tmp = (uint64_t)opae_rtm_info.ports_per_retimer *
> +
> 	(uint64_t)opae_rtm_info.nums_retimer;
>  		*attr_value = tmp;
>  		return 0;
>  	}
> @@ -547,8 +547,8 @@
>  	if (!strcmp(attr_name, "NICSideLinkPortNum")) {
>  		if (opae_manager_get_retimer_info(mgr, &opae_rtm_info))
>  			return -1;
> -		uint64_t tmp = opae_rtm_info.nums_fvl *
> -					opae_rtm_info.ports_per_fvl;
> +		uint64_t tmp = (uint64_t)opae_rtm_info.nums_fvl *
> +
> 	(uint64_t)opae_rtm_info.ports_per_fvl;
>  		*attr_value = tmp;
>  		return 0;
>  	}
> --
> 1.8.3.1



More information about the dev mailing list