]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.129/net-mlx5-fix-debugfs-cleanup-in-the-device-init-remove-flow.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.129 / net-mlx5-fix-debugfs-cleanup-in-the-device-init-remove-flow.patch
CommitLineData
175dacaf
GKH
1From foo@baz Thu Sep 20 09:30:23 CEST 2018
2From: Jack Morgenstein <jackm@dev.mellanox.co.il>
3Date: Tue, 7 Aug 2018 09:59:03 +0300
4Subject: net/mlx5: Fix debugfs cleanup in the device init/remove flow
5
6From: Jack Morgenstein <jackm@dev.mellanox.co.il>
7
8[ Upstream commit 5df816e7f43f1297c40021ef17ec6e722b45c82f ]
9
10When initializing the device (procedure init_one), the driver
11calls mlx5_pci_init to perform pci initialization. As part of this
12initialization, mlx5_pci_init creates a debugfs directory.
13If this creation fails, init_one aborts, returning failure to
14the caller (which is the probe method caller).
15
16The main reason for such a failure to occur is if the debugfs
17directory already exists. This can happen if the last time
18mlx5_pci_close was called, debugfs_remove (silently) failed due
19to the debugfs directory not being empty.
20
21Guarantee that such a debugfs_remove failure will not occur by
22instead calling debugfs_remove_recursive in procedure mlx5_pci_close.
23
24Fixes: 59211bd3b632 ("net/mlx5: Split the load/unload flow into hardware and software flows")
25Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
26Reviewed-by: Daniel Jurgens <danielj@mellanox.com>
27Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
28Signed-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)