From: Michael Baum Date: Sun, 12 Sep 2021 10:36:24 +0000 (+0300) Subject: net/mlx5: fix PF leak on PCI probing failure X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=6856efa54eea23ce2079a23cb661e009421fb833;p=dpdk.git net/mlx5: fix PF leak on PCI probing failure During PCI probe, the internal probe function is called per PF. If one of them fails, it was missing a proper destroy for the previously probed PFs. This fixes the behavior by destroying all previously probed PFs. Fixes: 08c2772fc747 ("net/mlx5: support list of representor PF") Cc: stable@dpdk.org Signed-off-by: Michael Baum Acked-by: Matan Azrad --- diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 470b16cb9a..880ddf7ee2 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -2697,9 +2697,20 @@ mlx5_os_pci_probe(struct rte_pci_device *pci_dev) if (eth_da.nb_ports > 0) { /* Iterate all port if devargs pf is range: "pf[0-1]vf[...]". */ - for (p = 0; p < eth_da.nb_ports; p++) + for (p = 0; p < eth_da.nb_ports; p++) { ret = mlx5_os_pci_probe_pf(pci_dev, ð_da, eth_da.ports[p]); + if (ret) + break; + } + if (ret) { + DRV_LOG(ERR, "Probe of PCI device " PCI_PRI_FMT " " + "aborted due to proding failure of PF %u", + pci_dev->addr.domain, pci_dev->addr.bus, + pci_dev->addr.devid, pci_dev->addr.function, + eth_da.ports[p]); + mlx5_net_remove(&pci_dev->device); + } } else { ret = mlx5_os_pci_probe_pf(pci_dev, ð_da, 0); } diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index f0ec2d1279..02ea2e781e 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -2386,7 +2386,7 @@ mlx5_eth_find_next(uint16_t port_id, struct rte_device *odev) * @return * 0 on success, the function cannot fail. */ -static int +int mlx5_net_remove(struct rte_device *dev) { uint16_t port_id; diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index e02714e231..3581414b78 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1483,6 +1483,7 @@ int mlx5_udp_tunnel_port_add(struct rte_eth_dev *dev, struct rte_eth_udp_tunnel *udp_tunnel); uint16_t mlx5_eth_find_next(uint16_t port_id, struct rte_device *odev); int mlx5_dev_close(struct rte_eth_dev *dev); +int mlx5_net_remove(struct rte_device *dev); bool mlx5_is_hpf(struct rte_eth_dev *dev); bool mlx5_is_sf_repr(struct rte_eth_dev *dev); void mlx5_age_event_prepare(struct mlx5_dev_ctx_shared *sh);