mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mario Limonciello <superm1@kernel.org>
To: "Guangshuo Li" <lgs201920130244@gmail.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: stable@vger.kernel.org
Subject: Re: [PATCH] platform/x86/amd/hfi: fix platform device leak on init failure
Date: Mon, 21 Sep 2026 08:43:32 -0500	[thread overview]
Message-ID: <ebdcd24a-dbca-4195-a9f1-ba224596b7d7@kernel.org> (raw)
In-Reply-To: <20260921082609.244774-1-lgs201920130244@gmail.com>



On 9/21/26 03:26, Guangshuo Li wrote:
> 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>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
> ---
>   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;
>   }

  reply	other threads:[~2026-09-21 13:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21  8:26 Guangshuo Li
2026-09-21 13:43 ` Mario Limonciello [this message]
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

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=ebdcd24a-dbca-4195-a9f1-ba224596b7d7@kernel.org \
    --to=superm1@kernel.org \
    --cc=bp@alien8.de \
    --cc=gautham.shenoy@amd.com \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=lgs201920130244@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --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®