From: Andy Pei Date: Wed, 22 May 2019 06:36:34 +0000 (+0800) Subject: raw/ifpga: fix unintentional integer overflow X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=79f52bff01d0fbbcbb2467bddbdda164d2bad7d4;p=dpdk.git 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: stable@dpdk.org Signed-off-by: Andy Pei Acked-by: Rosen Xu --- diff --git a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c index 01aa917dec..fef89e6bc5 100644 --- a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c +++ b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c @@ -499,8 +499,8 @@ ifpga_rawdev_get_attr(struct rte_rawdev *dev, 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; } @@ -552,8 +552,8 @@ ifpga_rawdev_get_attr(struct rte_rawdev *dev, 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; }