* [PATCH] mlxsw: core_hwmon: unregister the hwmon device on event ops failure
@ 2026-11-03 10:28 Wentao Liang
2026-11-03 10:33 ` netdev-bot+sinfo
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Wentao Liang @ 2026-11-03 10:28 UTC (permalink / raw)
To: Ido Schimmel, Petr Machata, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: netdev, linux-kernel, Wentao Liang, stable
If mlxsw_linecards_event_ops_register() fails, the error path calls
hwmon_device_unregister() with line_cards[0].hwmon_dev, but that field
is assigned only after the registration succeeds and is therefore
still NULL. The hwmon device returned by
hwmon_device_register_with_groups() is never unregistered, and the
error path dereferences a NULL device.
Unregister the hwmon_dev local variable instead.
Fixes: 99a03b3193f6 ("mlxsw: core_hwmon: Add interfaces for line card initialization and de-initialization")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
index a5e7aee730d6..16644f367df6 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
@@ -920,7 +920,7 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
return 0;
err_linecards_event_ops_register:
- hwmon_device_unregister(mlxsw_hwmon->line_cards[0].hwmon_dev);
+ hwmon_device_unregister(hwmon_dev);
err_hwmon_register:
err_temp_gearbox_init:
err_temp_module_init:
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mlxsw: core_hwmon: unregister the hwmon device on event ops failure
2026-11-03 10:28 [PATCH] mlxsw: core_hwmon: unregister the hwmon device on event ops failure Wentao Liang
@ 2026-11-03 10:33 ` netdev-bot+sinfo
2026-11-06 16:24 ` Petr Machata
2026-11-06 23:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: netdev-bot+sinfo @ 2026-11-03 10:33 UTC (permalink / raw)
To: Wentao Liang
Cc: Ido Schimmel, Petr Machata, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel,
stable
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by code inspection). If it was triggered please include
the symptoms, like the stack trace or error messages.
- What hardware the change was tested on. For driver fixes please
mention the device (and if relevant firmware version) used for
testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account. If the series needs another revision for
other reasons, please include the information in the commit messages
then.
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mlxsw: core_hwmon: unregister the hwmon device on event ops failure
2026-11-03 10:28 [PATCH] mlxsw: core_hwmon: unregister the hwmon device on event ops failure Wentao Liang
2026-11-03 10:33 ` netdev-bot+sinfo
@ 2026-11-06 16:24 ` Petr Machata
2026-11-06 23:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Petr Machata @ 2026-11-06 16:24 UTC (permalink / raw)
To: Wentao Liang
Cc: Ido Schimmel, Petr Machata, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel,
stable
Wentao Liang <vulab@iscas.ac.cn> writes:
> If mlxsw_linecards_event_ops_register() fails, the error path calls
> hwmon_device_unregister() with line_cards[0].hwmon_dev, but that field
> is assigned only after the registration succeeds and is therefore
> still NULL. The hwmon device returned by
> hwmon_device_register_with_groups() is never unregistered, and the
> error path dereferences a NULL device.
>
> Unregister the hwmon_dev local variable instead.
>
> Fixes: 99a03b3193f6 ("mlxsw: core_hwmon: Add interfaces for line card initialization and de-initialization")
> Cc: stable@vger.kernel.org
> Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Reviewed-by: Petr Machata <petrm@nvidia.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mlxsw: core_hwmon: unregister the hwmon device on event ops failure
2026-11-03 10:28 [PATCH] mlxsw: core_hwmon: unregister the hwmon device on event ops failure Wentao Liang
2026-11-03 10:33 ` netdev-bot+sinfo
2026-11-06 16:24 ` Petr Machata
@ 2026-11-06 23:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-11-06 23:10 UTC (permalink / raw)
To: Wentao Liang
Cc: idosch, petrm, andrew+netdev, davem, edumazet, kuba, pabeni,
netdev, linux-kernel, stable
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 3 Nov 2026 10:28:50 +0000 you wrote:
> If mlxsw_linecards_event_ops_register() fails, the error path calls
> hwmon_device_unregister() with line_cards[0].hwmon_dev, but that field
> is assigned only after the registration succeeds and is therefore
> still NULL. The hwmon device returned by
> hwmon_device_register_with_groups() is never unregistered, and the
> error path dereferences a NULL device.
>
> [...]
Here is the summary with links:
- mlxsw: core_hwmon: unregister the hwmon device on event ops failure
https://git.kernel.org/netdev/net-next/c/08f643794931
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-06 23:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 10:28 [PATCH] mlxsw: core_hwmon: unregister the hwmon device on event ops failure Wentao Liang
2026-11-03 10:33 ` netdev-bot+sinfo
2026-11-06 16:24 ` Petr Machata
2026-11-06 23:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®