[PATCH] platform: mellanox: unregister the fan device on probe failure
From: Wentao Liang
Date: Tue Nov 03 2026 - 07:44:57 EST
mlxplat_platdevs_init() registers the mlxreg-fan platform device before
the watchdog and DPU devices, but the error paths for those later
registrations never unregister it: the cleanup chain below
fail_platform_wd_register drops the watchdog, io, LED and hotplug
devices, but not the fan.
Unregister the fan device on those failure paths.
Fixes: 158cd8320776 ("platform: mellanox: Split logic in init and exit flow")
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/platform/mellanox/mlx-platform.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/platform/mellanox/mlx-platform.c b/drivers/platform/mellanox/mlx-platform.c
index efcba68d3aa5..303721604c96 100644
--- a/drivers/platform/mellanox/mlx-platform.c
+++ b/drivers/platform/mellanox/mlx-platform.c
@@ -8389,6 +8389,8 @@ static int mlxplat_platdevs_init(struct mlxplat_priv *priv)
fail_platform_wd_register:
while (i--)
platform_device_unregister(priv->pdev_wd[i]);
+ if (mlxplat_fan)
+ platform_device_unregister(priv->pdev_fan);
fail_platform_fan_register:
if (mlxplat_regs_io)
platform_device_unregister(priv->pdev_io_regs);
--
2.34.1