raw/ifpga: fix unintentional integer overflow
authorAndy Pei <andy.pei@intel.com>
Wed, 22 May 2019 06:36:34 +0000 (14:36 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 4 Jul 2019 13:49:59 +0000 (15:49 +0200)
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 <andy.pei@intel.com>
Acked-by: Rosen Xu <rosen.xu@intel.com>
drivers/raw/ifpga_rawdev/ifpga_rawdev.c

index 01aa917..fef89e6 100644 (file)
@@ -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;
        }