Skip to content

Commit

Permalink
net/nfp: fix resource leak for VF
Browse files Browse the repository at this point in the history
Fix the resource leak problem in the logic of VF.

Fixes: f26e823 ("net/nfp: implement xstats")
Cc: james.hershaw@corigine.com
Cc: stable@dpdk.org

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
  • Loading branch information
hechaoyong authored and ovsrobot committed Dec 4, 2023
1 parent dd711bb commit cadacb7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/net/nfp/nfp_ethdev_vf.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,17 @@ nfp_netvf_set_link_down(struct rte_eth_dev *dev __rte_unused)
static int
nfp_netvf_close(struct rte_eth_dev *dev)
{
struct nfp_net_hw *net_hw;
struct rte_pci_device *pci_dev;

if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;

net_hw = dev->data->dev_private;
pci_dev = RTE_ETH_DEV_TO_PCI(dev);

rte_free(net_hw->eth_xstats_base);

/*
* We assume that the DPDK application is stopping all the
* threads/queues before calling the device close function.
Expand Down Expand Up @@ -323,7 +327,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
if (eth_dev->data->mac_addrs == NULL) {
PMD_INIT_LOG(ERR, "Failed to space for MAC address");
err = -ENOMEM;
goto dev_err_ctrl_map;
goto free_xstats;
}

nfp_read_mac(hw);
Expand Down Expand Up @@ -360,8 +364,8 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)

return 0;

dev_err_ctrl_map:
nfp_cpp_area_free(net_hw->ctrl_area);
free_xstats:
rte_free(net_hw->eth_xstats_base);

return err;
}
Expand Down

0 comments on commit cadacb7

Please sign in to comment.