Skip to contentSkip to conversation

net/mlx5: Always drain health in shutdown callback

PATCH New Xiangyu Chen 1 participant 1 message Oct 10, 2024 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: Always drain health in shutdown callback

From: Shay Drory <[email protected]>

[ Upstream commit 1b75da22ed1e6171e261bc9265370162553d5393 ]

There is no point in recovery during device shutdown. if health work started need to wait for it to avoid races and NULL pointer access.

Hence, drain health WQ on shutdown callback.

Fixes 1958fc2f0712 ("net/mlx5: SF, Add auxiliary device driver")
Fixes d2aa060d40fa ("net/mlx5: Cancel health poll before sending panic teardown command")
[Xiangyu: Modified to apply on 6.1.y to fix CVE-2024-43866]
---
 drivers/net/ethernet/mellanox/mlx5/core/main.c          | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/main.c +1 -1
index 76af59cfdd0e..825ad7663fa4 100644
@@ -1950,7 +1950,6 @@ static int mlx5_try_fast_unload(struct mlx5_core_dev *dev)
 	/* Panic tear down fw command will stop the PCI bus communication
 	 * with the HCA, so the health poll is no longer needed.
 	 */
-	mlx5_drain_health_wq(dev);
 	mlx5_stop_health_poll(dev, false);
 
 	ret = mlx5_cmd_fast_teardown_hca(dev);
@@ -1985,6 +1984,7 @@ static void shutdown(struct pci_dev *pdev)
 
 	mlx5_core_info(dev, "Shutdown was called\n");
 	set_bit(MLX5_BREAK_FW_WAIT, &dev->intf_state);
+	mlx5_drain_health_wq(dev);
 	err = mlx5_try_fast_unload(dev);
 	if (err)
 		mlx5_unload_one(dev, false);
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c +1 -0
index 2424cdf9cca9..d6850eb0ed7f 100644
@@ -75,6 +75,7 @@ static void mlx5_sf_dev_shutdown(struct auxiliary_device *adev)
 {
 	struct mlx5_sf_dev *sf_dev = container_of(adev, struct mlx5_sf_dev, adev);
 
+	mlx5_drain_health_wq(sf_dev->mdev);
 	mlx5_unload_one(sf_dev->mdev, false);
 }
 
Signature · 1 line
2.43.0