Re: [PATCH] ieee802154: fakelb: release platform device if driver registration fails

From: Miquel Raynal

Date: Mon Nov 16 2026 - 09:59:35 EST


On 03/11/2026 at 10:28:54 GMT, Wentao Liang <vulab@xxxxxxxxxxx> wrote:

> fakelb_init_module() registers a platform device and then registers the
> platform driver, returning the result of the latter directly. If driver
> registration fails, module initialization fails and the module exit
> function is never run, so the platform device is never unregistered and
> leaks.
>
> Check the result of platform_driver_register() and unregister the device
> on failure. Also check the device registration result, which can be an
> ERR_PTR, before using the stored pointer.
>
> Fixes: e1e49b641387 ("drivers/ieee802154: IEEE 802.15.4 loopback driver")
> Cc: stable@xxxxxxxxxxxxxxx
> Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
> Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>

I don't think it is super useful, but it's not wrong either.

Reviewed-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>