net/mlx5: Nullify qp->dbg pointer post destruction
authorPatrisious Haddad <phaddad@nvidia.com>
Mon, 5 Jun 2023 10:14:04 +0000 (13:14 +0300)
committerLeon Romanovsky <leon@kernel.org>
Sun, 11 Jun 2023 08:21:23 +0000 (11:21 +0300)
Nullifying qp->dbg is a preparation for the next patches
from the series in which mlx5_core_destroy_qp() could actually fail,
and then it can be called again which causes a kernel crash, since
qp->dbg was not nullified in previous call.

Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
Link: https://lore.kernel.org/r/1677e52bb642fd8d6062d73a5aa69083c0283dc9.1685953497.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/debugfs.c

index bb95b40d25eb5d224f1d424f0d111d8ca441d94c..b08b5695ee457e9357e435eedeedb4050d892c56 100644 (file)
@@ -513,11 +513,11 @@ EXPORT_SYMBOL(mlx5_debug_qp_add);
 
 void mlx5_debug_qp_remove(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp)
 {
-       if (!mlx5_debugfs_root)
+       if (!mlx5_debugfs_root || !qp->dbg)
                return;
 
-       if (qp->dbg)
-               rem_res_tree(qp->dbg);
+       rem_res_tree(qp->dbg);
+       qp->dbg = NULL;
 }
 EXPORT_SYMBOL(mlx5_debug_qp_remove);