From: Guangshuo Li <lgs201920130244@gmail.com>
To: "Mario Limonciello" <mario.limonciello@amd.com>,
"Perry Yuan" <perry.yuan@amd.com>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Gautham R. Shenoy" <gautham.shenoy@amd.com>,
"Borislav Petkov (AMD)" <bp@alien8.de>,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Guangshuo Li <lgs201920130244@gmail.com>, stable@vger.kernel.org
Subject: [PATCH] platform/x86/amd/hfi: fix platform device leak on init failure
Date: Mon, 21 Sep 2026 16:26:09 +0800 [thread overview]
Message-ID: <20260921082609.244774-1-lgs201920130244@gmail.com> (raw)
amd_hfi_init() registers the HFI platform device before registering
the platform driver. If platform_driver_register() fails, the function
returns the error without unregistering the already registered platform
device.
Since the failed init path does not run amd_hfi_exit(), the platform
device remains registered and its reference is never dropped, preventing
the associated platform object from being released.
Unregister the platform device when platform driver registration fails
to properly unwind the successful device registration.
The issue was identified by a static analysis tool I developed and
confirmed by manual review.
Fixes: 5d902ee5609a ("platform/x86: hfi: Introduce AMD Hardware Feedback Interface Driver")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
drivers/platform/x86/amd/hfi/hfi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/amd/hfi/hfi.c b/drivers/platform/x86/amd/hfi/hfi.c
index e0ebcb0c4acd..449aad914ad1 100644
--- a/drivers/platform/x86/amd/hfi/hfi.c
+++ b/drivers/platform/x86/amd/hfi/hfi.c
@@ -530,8 +530,10 @@ static int __init amd_hfi_init(void)
}
ret = platform_driver_register(&amd_hfi_driver);
- if (ret)
+ if (ret) {
pr_err("failed to register HFI driver\n");
+ platform_device_unregister(device);
+ }
return ret;
}
--
2.43.0
next reply other threads:[~2026-09-21 8:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 8:26 Guangshuo Li [this message]
2026-09-21 13:43 ` Mario Limonciello
2026-09-21 17:29 ` Mario Limonciello
2026-09-21 15:04 ` krzk
2026-09-21 15:07 ` krzk
2026-09-21 15:15 ` krzk
2026-09-21 22:03 ` Krzysztof Kozlowski
2026-09-22 2:11 ` Guangshuo Li
2026-09-22 3:05 ` Borislav Petkov
2026-09-22 6:25 ` Guangshuo Li
2026-10-08 17:37 ` Ilpo Järvinen
2026-10-08 20:04 ` Mario Limonciello
2026-10-09 10:24 ` Ilpo Järvinen
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=20260921082609.244774-1-lgs201920130244@gmail.com \
--to=lgs201920130244@gmail.com \
--cc=bp@alien8.de \
--cc=gautham.shenoy@amd.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=perry.yuan@amd.com \
--cc=platform-driver-x86@vger.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®