Linux driver-core infrastructure
 help / color / mirror / Atom feed
* [PATCH] driver core: platform: fix fwnode leak on registration failure
@ 2026-11-02  8:28 Johan Hovold
  2026-11-02 13:51 ` Bartosz Golaszewski
  2026-11-02 16:30 ` Danilo Krummrich
  0 siblings, 2 replies; 3+ messages in thread
From: Johan Hovold @ 2026-11-02  8:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Johan Hovold
  Cc: driver-core, linux-kernel, stable, Bartosz Golaszewski

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@vger.kernel.org	# 7.3
Cc: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/base/platform.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 3593d45f4a7a..979593e5cca1 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -971,7 +971,6 @@ struct platform_device *platform_device_register_full(const struct platform_devi
 	ret = platform_device_add(pdev);
 	if (ret) {
 err:
-		ACPI_COMPANION_SET(&pdev->dev, NULL);
 		platform_device_put(pdev);
 		return ERR_PTR(ret);
 	}
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] driver core: platform: fix fwnode leak on registration failure
  2026-11-02  8:28 [PATCH] driver core: platform: fix fwnode leak on registration failure Johan Hovold
@ 2026-11-02 13:51 ` Bartosz Golaszewski
  2026-11-02 16:30 ` Danilo Krummrich
  1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2026-11-02 13:51 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	driver-core, linux-kernel, stable, Bartosz Golaszewski

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@vger.kernel.org	# 7.3
> Cc: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
 
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] driver core: platform: fix fwnode leak on registration failure
  2026-11-02  8:28 [PATCH] driver core: platform: fix fwnode leak on registration failure Johan Hovold
  2026-11-02 13:51 ` Bartosz Golaszewski
@ 2026-11-02 16:30 ` Danilo Krummrich
  1 sibling, 0 replies; 3+ messages in thread
From: Danilo Krummrich @ 2026-11-02 16:30 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, Danilo Krummrich,
	driver-core, linux-kernel, stable, Bartosz Golaszewski

On Mon,  2 Nov 2026 09:28:22 +0100, Johan Hovold wrote:
> [PATCH] driver core: platform: fix fwnode leak on registration failure

Applied, thanks!

  Branch: driver-core-testing
  Tree:   git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git

[1/1] driver core: platform: fix fwnode leak on registration failure
      commit: 7b4c25424cf5

The patch will appear in the next linux-next integration (typically within 24
hours on weekdays).

The patch is in the driver-core-testing branch and will be promoted to
driver-core-next after validation.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-02 16:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-02  8:28 [PATCH] driver core: platform: fix fwnode leak on registration failure Johan Hovold
2026-11-02 13:51 ` Bartosz Golaszewski
2026-11-02 16:30 ` Danilo Krummrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox