]>
Commit | Line | Data |
---|---|---|
175dacaf GKH |
1 | From foo@baz Thu Sep 20 09:30:23 CEST 2018 |
2 | From: Jack Morgenstein <jackm@dev.mellanox.co.il> | |
3 | Date: Tue, 7 Aug 2018 09:59:03 +0300 | |
4 | Subject: net/mlx5: Fix debugfs cleanup in the device init/remove flow | |
5 | ||
6 | From: Jack Morgenstein <jackm@dev.mellanox.co.il> | |
7 | ||
8 | [ Upstream commit 5df816e7f43f1297c40021ef17ec6e722b45c82f ] | |
9 | ||
10 | When initializing the device (procedure init_one), the driver | |
11 | calls mlx5_pci_init to perform pci initialization. As part of this | |
12 | initialization, mlx5_pci_init creates a debugfs directory. | |
13 | If this creation fails, init_one aborts, returning failure to | |
14 | the caller (which is the probe method caller). | |
15 | ||
16 | The main reason for such a failure to occur is if the debugfs | |
17 | directory already exists. This can happen if the last time | |
18 | mlx5_pci_close was called, debugfs_remove (silently) failed due | |
19 | to the debugfs directory not being empty. | |
20 | ||
21 | Guarantee that such a debugfs_remove failure will not occur by | |
22 | instead calling debugfs_remove_recursive in procedure mlx5_pci_close. | |
23 | ||
24 | Fixes: 59211bd3b632 ("net/mlx5: Split the load/unload flow into hardware and software flows") | |
25 | Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il> | |
26 | Reviewed-by: Daniel Jurgens <danielj@mellanox.com> | |
27 | Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> | |
28 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
29 | --- | |
30 | drivers/net/ethernet/mellanox/mlx5/core/main.c | 6 ++++-- | |
31 | 1 file changed, 4 insertions(+), 2 deletions(-) | |
32 | ||
33 | --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c | |
34 | +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c | |
35 | @@ -787,8 +787,10 @@ static int mlx5_pci_init(struct mlx5_cor | |
36 | priv->numa_node = dev_to_node(&dev->pdev->dev); | |
37 | ||
38 | priv->dbg_root = debugfs_create_dir(dev_name(&pdev->dev), mlx5_debugfs_root); | |
39 | - if (!priv->dbg_root) | |
40 | + if (!priv->dbg_root) { | |
41 | + dev_err(&pdev->dev, "Cannot create debugfs dir, aborting\n"); | |
42 | return -ENOMEM; | |
43 | + } | |
44 | ||
45 | err = mlx5_pci_enable_device(dev); | |
46 | if (err) { | |
47 | @@ -837,7 +839,7 @@ static void mlx5_pci_close(struct mlx5_c | |
48 | pci_clear_master(dev->pdev); | |
49 | release_bar(dev->pdev); | |
50 | mlx5_pci_disable_device(dev); | |
51 | - debugfs_remove(priv->dbg_root); | |
52 | + debugfs_remove_recursive(priv->dbg_root); | |
53 | } | |
54 | ||
55 | static int mlx5_init_once(struct mlx5_core_dev *dev, struct mlx5_priv *priv) |