app/testpmd: fix integer overflow
authorJasvinder Singh <jasvinder.singh@intel.com>
Thu, 19 Oct 2017 09:38:18 +0000 (10:38 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 26 Oct 2017 00:33:00 +0000 (02:33 +0200)
Fixed integer overflow by casting link_params.link_speed to
uint64_t type.

Coverity issue: 195016
Fixes: 5b590fbe09b6 ("app/testpmd: add traffic management forwarding mode")

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
app/test-pmd/tm.c

index da1adda..dd837cb 100644 (file)
@@ -335,7 +335,7 @@ set_tm_hiearchy_nodes_shaper_rate(portid_t port_id, struct tm_hierarchy *h)
        memset(&link_params, 0, sizeof(link_params));
 
        rte_eth_link_get(port_id, &link_params);
-       tm_port_rate = link_params.link_speed * BYTES_IN_MBPS;
+       tm_port_rate = (uint64_t)link_params.link_speed * BYTES_IN_MBPS;
 
        if (tm_port_rate > UINT32_MAX)
                tm_port_rate = UINT32_MAX;