Skip to content

Commit 6d1659b

Browse files
Jack Morgensteingregkh
authored andcommitted
net/mlx5: Fix debugfs cleanup in the device init/remove flow
[ Upstream commit 5df816e7f43f1297c40021ef17ec6e722b45c82f ] When initializing the device (procedure init_one), the driver calls mlx5_pci_init to perform pci initialization. As part of this initialization, mlx5_pci_init creates a debugfs directory. If this creation fails, init_one aborts, returning failure to the caller (which is the probe method caller). The main reason for such a failure to occur is if the debugfs directory already exists. This can happen if the last time mlx5_pci_close was called, debugfs_remove (silently) failed due to the debugfs directory not being empty. Guarantee that such a debugfs_remove failure will not occur by instead calling debugfs_remove_recursive in procedure mlx5_pci_close. Fixes: 59211bd ("net/mlx5: Split the load/unload flow into hardware and software flows") Signed-off-by: Jack Morgenstein <[email protected]> Reviewed-by: Daniel Jurgens <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ccb8961 commit 6d1659b

File tree

1 file changed

+4
-2
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+4
-2
lines changed

drivers/net/ethernet/mellanox/mlx5/core/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,8 +787,10 @@ static int mlx5_pci_init(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
787787
priv->numa_node = dev_to_node(&dev->pdev->dev);
788788

789789
priv->dbg_root = debugfs_create_dir(dev_name(&pdev->dev), mlx5_debugfs_root);
790-
if (!priv->dbg_root)
790+
if (!priv->dbg_root) {
791+
dev_err(&pdev->dev, "Cannot create debugfs dir, aborting\n");
791792
return -ENOMEM;
793+
}
792794

793795
err = mlx5_pci_enable_device(dev);
794796
if (err) {
@@ -837,7 +839,7 @@ static void mlx5_pci_close(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
837839
pci_clear_master(dev->pdev);
838840
release_bar(dev->pdev);
839841
mlx5_pci_disable_device(dev);
840-
debugfs_remove(priv->dbg_root);
842+
debugfs_remove_recursive(priv->dbg_root);
841843
}
842844

843845
static int mlx5_init_once(struct mlx5_core_dev *dev, struct mlx5_priv *priv)

0 commit comments

Comments
 (0)