From: Johan Hovold <johan@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Johan Hovold <johan@kernel.org>
Cc: driver-core@lists.linux.dev, linux-kernel@vger.kernel.org,
stable@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Subject: [PATCH] driver core: platform: fix fwnode leak on registration failure
Date: Mon, 2 Nov 2026 09:28:22 +0100 [thread overview]
Message-ID: <20261102082822.1275425-1-johan@kernel.org> (raw)
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
next reply other threads:[~2026-11-02 8:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 8:28 Johan Hovold [this message]
2026-11-02 13:51 ` Bartosz Golaszewski
2026-11-02 16:30 ` Danilo Krummrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261102082822.1275425-1-johan@kernel.org \
--to=johan@kernel.org \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®