pcapng: handle failure of link status query
authorStephen Hemminger <stephen@networkplumber.org>
Thu, 10 Feb 2022 23:09:04 +0000 (15:09 -0800)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 8 Mar 2022 08:19:40 +0000 (09:19 +0100)
If rte_ethlink_get fails, the code can just not add speed
to the pcap file.

Coverity issue: 373664
Fixes: 8d23ce8f5ee9 ("pcapng: add new library for writing pcapng files")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
lib/pcapng/rte_pcapng.c

index 5ae96a5..90b2f5b 100644 (file)
@@ -176,8 +176,8 @@ pcapng_add_interface(rte_pcapng_t *self, uint16_t port)
                         "%s-%s", dev->bus->name, dev->name);
 
        /* DPDK reports in units of Mbps */
-       rte_eth_link_get(port, &link);
-       if (link.link_status == RTE_ETH_LINK_UP)
+       if (rte_eth_link_get(port, &link) == 0 &&
+           link.link_status == RTE_ETH_LINK_UP)
                speed = link.link_speed * PCAPNG_MBPS_SPEED;
 
        if (rte_eth_macaddr_get(port, &macaddr) < 0)