mirror of https://lore.kernel.org/lkml/
 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	[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

all inboxes | Powered by JetHome®