net/ixgbe: fix MAC resource leak
authorQiming Chen <chenqiming_huawei@163.com>
Wed, 1 Sep 2021 07:12:07 +0000 (15:12 +0800)
committerQi Zhang <qi.z.zhang@intel.com>
Mon, 6 Sep 2021 01:44:58 +0000 (03:44 +0200)
In the eth_ixgbevf_dev_init and eth_ixgbe_dev_init functions, memory is
allocated for the MAC address, and the address is stored in the
eth_dev->data->mac_addrs member variable. If the subsequent function is
abnormal, you need to use the rte_free function to release the MAC
address memory.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org
Signed-off-by: Qiming Chen <chenqiming_huawei@163.com>
Acked-by: Haiyue Wang <haiyue.wang@intel.com>
drivers/net/ixgbe/ixgbe_ethdev.c

index 3371a7d..47693c0 100644 (file)
@@ -1218,6 +1218,8 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
                PMD_INIT_LOG(ERR,
                             "Failed to allocate %d bytes needed to store MAC addresses",
                             RTE_ETHER_ADDR_LEN * IXGBE_VMDQ_NUM_UC_MAC);
+               rte_free(eth_dev->data->mac_addrs);
+               eth_dev->data->mac_addrs = NULL;
                return -ENOMEM;
        }
 
@@ -1667,6 +1669,8 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
 
        default:
                PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
+               rte_free(eth_dev->data->mac_addrs);
+               eth_dev->data->mac_addrs = NULL;
                return -EIO;
        }