aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Morgenstein <jackm@dev.mellanox.co.il>2018-08-07 02:59:03 -0400
committerSaeed Mahameed <saeedm@mellanox.com>2018-09-05 20:08:33 -0400
commit5df816e7f43f1297c40021ef17ec6e722b45c82f (patch)
treea8118979964e07e150dd2f88b9d3aad2fe785c28
parent76d5581c870454be5f1f1a106c57985902e7ea20 (diff)
net/mlx5: Fix debugfs cleanup in the device init/remove flow
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: 59211bd3b632 ("net/mlx5: Split the load/unload flow into hardware and software flows") Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il> Reviewed-by: Daniel Jurgens <danielj@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/main.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index 739aad0a0b35..b5e9f664fc66 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -878,8 +878,10 @@ static int mlx5_pci_init(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
878 priv->numa_node = dev_to_node(&dev->pdev->dev); 878 priv->numa_node = dev_to_node(&dev->pdev->dev);
879 879
880 priv->dbg_root = debugfs_create_dir(dev_name(&pdev->dev), mlx5_debugfs_root); 880 priv->dbg_root = debugfs_create_dir(dev_name(&pdev->dev), mlx5_debugfs_root);
881 if (!priv->dbg_root) 881 if (!priv->dbg_root) {
882 dev_err(&pdev->dev, "Cannot create debugfs dir, aborting\n");
882 return -ENOMEM; 883 return -ENOMEM;
884 }
883 885
884 err = mlx5_pci_enable_device(dev); 886 err = mlx5_pci_enable_device(dev);
885 if (err) { 887 if (err) {
@@ -928,7 +930,7 @@ static void mlx5_pci_close(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
928 pci_clear_master(dev->pdev); 930 pci_clear_master(dev->pdev);
929 release_bar(dev->pdev); 931 release_bar(dev->pdev);
930 mlx5_pci_disable_device(dev); 932 mlx5_pci_disable_device(dev);
931 debugfs_remove(priv->dbg_root); 933 debugfs_remove_recursive(priv->dbg_root);
932} 934}
933 935
934static int mlx5_init_once(struct mlx5_core_dev *dev, struct mlx5_priv *priv) 936static int mlx5_init_once(struct mlx5_core_dev *dev, struct mlx5_priv *priv)