Skip to content

Commit

Permalink
net/hns3: fix memory leak on secondary process exit
Browse files Browse the repository at this point in the history
[ upstream commit 4101114 ]

The secondary process is applied a memory for the process_private
during initialization. Therefore, the memory needs to be released
when exiting.

Fixes: c203571 ("net/hns3: register and add log interface")

Signed-off-by: Lijun Ou <oulijun@huawei.com>
  • Loading branch information
oulijun authored and bluca committed Feb 4, 2021
1 parent 99e743b commit 89796f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 5 additions & 2 deletions drivers/net/hns3/hns3_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -6226,8 +6226,11 @@ hns3_dev_uninit(struct rte_eth_dev *eth_dev)

PMD_INIT_FUNC_TRACE();

if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return -EPERM;
if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
rte_free(eth_dev->process_private);
eth_dev->process_private = NULL;
return 0;
}

if (hw->adapter_state < HNS3_NIC_CLOSING)
hns3_dev_close(eth_dev);
Expand Down
12 changes: 9 additions & 3 deletions drivers/net/hns3/hns3_ethdev_vf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1977,8 +1977,11 @@ hns3vf_dev_close(struct rte_eth_dev *eth_dev)
struct hns3_hw *hw = &hns->hw;
int ret = 0;

if (rte_eal_process_type() != RTE_PROC_PRIMARY)
if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
rte_free(eth_dev->process_private);
eth_dev->process_private = NULL;
return 0;
}

if (hw->adapter_state == HNS3_NIC_STARTED)
ret = hns3vf_dev_stop(eth_dev);
Expand Down Expand Up @@ -2848,8 +2851,11 @@ hns3vf_dev_uninit(struct rte_eth_dev *eth_dev)

PMD_INIT_FUNC_TRACE();

if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return -EPERM;
if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
rte_free(eth_dev->process_private);
eth_dev->process_private = NULL;
return 0;
}

if (hw->adapter_state < HNS3_NIC_CLOSING)
hns3vf_dev_close(eth_dev);
Expand Down

0 comments on commit 89796f0

Please sign in to comment.