net/hinic: fix hugepage memory leaks
authorGuoyang Zhou <zhouguoyang@huawei.com>
Fri, 20 Nov 2020 09:11:29 +0000 (17:11 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 20 Nov 2020 20:10:05 +0000 (21:10 +0100)
The 'nic_io' memory is set to NULL before it is freed, this is wrong,
and the freeing of some private port resources should be moved from the
".remove(device)" function to the ".dev_close(port)" function.

Fixes: f30e69b41f94 ("ethdev: add device flag to bypass auto-filled queue xstats")
Cc: stable@dpdk.org
Signed-off-by: Guoyang Zhou <zhouguoyang@huawei.com>
drivers/net/hinic/base/hinic_pmd_nicio.c
drivers/net/hinic/hinic_pmd_ethdev.c

index 576fe59..2736305 100644 (file)
@@ -664,7 +664,6 @@ err_init_nic_hwdev:
 static void hinic_free_nic_hwdev(struct hinic_hwdev *hwdev)
 {
        hinic_vf_func_free(hwdev);
-       hwdev->nic_io = NULL;
 }
 
 int hinic_rx_tx_flush(struct hinic_hwdev *hwdev)
index b694fd8..378f2c8 100644 (file)
@@ -1268,6 +1268,8 @@ static void hinic_disable_interrupt(struct rte_eth_dev *dev)
        if (retries == HINIC_INTR_CB_UNREG_MAX_RETRIES)
                PMD_DRV_LOG(ERR, "Unregister intr callback failed after %d retries",
                            retries);
+
+       rte_bit_relaxed_clear32(HINIC_DEV_INIT, &nic_dev->dev_status);
 }
 
 static int hinic_set_dev_promiscuous(struct hinic_nic_dev *nic_dev, bool enable)
@@ -1540,6 +1542,9 @@ static void hinic_deinit_mac_addr(struct rte_eth_dev *eth_dev)
 
        /* delete multicast mac addrs */
        hinic_delete_mc_addr_list(nic_dev);
+
+       rte_free(nic_dev->mc_list);
+
 }
 
 static int hinic_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
@@ -3006,6 +3011,9 @@ static int hinic_dev_close(struct rte_eth_dev *dev)
        /* disable hardware and uio interrupt */
        hinic_disable_interrupt(dev);
 
+       /* destroy rx mode mutex */
+       hinic_mutex_destroy(&nic_dev->rx_mode_mutex);
+
        /* deinit nic hardware device */
        hinic_nic_dev_destroy(dev);
 
@@ -3246,20 +3254,11 @@ static int hinic_dev_init(struct rte_eth_dev *eth_dev)
 
 static int hinic_dev_uninit(struct rte_eth_dev *dev)
 {
-       struct hinic_nic_dev *nic_dev;
-
-       nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
-       rte_bit_relaxed_clear32(HINIC_DEV_INIT, &nic_dev->dev_status);
-
        if (rte_eal_process_type() != RTE_PROC_PRIMARY)
                return 0;
 
-       hinic_mutex_destroy(&nic_dev->rx_mode_mutex);
-
        hinic_dev_close(dev);
 
-       rte_free(nic_dev->mc_list);
-
        return HINIC_OK;
 }