Re: [PATCH] mlxsw: core_hwmon: unregister the hwmon device on event ops failure
From: Petr Machata
Date: Fri Nov 06 2026 - 11:29:40 EST
Wentao Liang <vulab@xxxxxxxxxxx> 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@xxxxxxxxxxxxxxx
> Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
> Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
Reviewed-by: Petr Machata <petrm@xxxxxxxxxx>