Re: [PATCH] driver core: platform: fix fwnode leak on registration failure

From: Bartosz Golaszewski

Date: Mon Nov 02 2026 - 09:06:08 EST


On Mon, Nov 02, 2026 at 09:28:22AM +0100, Johan Hovold wrote:
> A recent change started taking a reference also to non-OF firmware nodes
> when registering platform devices.
>
> The firmware node pointer is however still cleared on registration
> failure when ACPI support is enabled, which means that the reference
> leaks in platform_device_release() when the device is freed.
>
> A software node also stays registered as device_remove_software_node()
> returns early.
>
> Drop the clearing of the fwnode pointer when registration fails to fix
> the leak.
>
> This issue was flagged by an LLM.
>
> Fixes: 7b5b51b2b05c ("driver core: platform: count references to all kinds of firmware nodes")
> Cc: stable@xxxxxxxxxxxxxxx # 7.3
> Cc: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
> Signed-off-by: Johan Hovold <johan@xxxxxxxxxx>
> ---

Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>