mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mario Limonciello <superm1@kernel.org>
To: Wentao Liang <vulab@iscas.ac.cn>, Shyam-sundar.S-k@amd.com
Cc: hansg@kernel.org, ilpo.jarvinen@linux.intel.com,
	linux-kernel@vger.kernel.org,
	platform-driver-x86@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] platform/x86/amd/pmf: Fix power supply leak in amd_pmf_get_battery_prop()
Date: Thu, 17 Sep 2026 13:02:27 -0500	[thread overview]
Message-ID: <55c9bb7f-33f0-4fb0-8fac-69d5660ac1bc@kernel.org> (raw)
In-Reply-To: <20260917140140.2154244-1-vulab@iscas.ac.cn>



On 9/17/26 09:01, Wentao Liang wrote:
> power_supply_get_by_name() takes a reference that is only dropped on
> the error path of power_supply_get_property(). Drop it as soon as the
> property has been read and stop searching, so that a successful lookup
> does not leak the reference.
> 
> Fixes: f4627dfd0e19 ("platform/x86/amd/pmf: Add support to get inputs from other subsystems")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>> ---
>   drivers/platform/x86/amd/pmf/spc.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
> index f48678a23cc7..cd957d7a4e48 100644
> --- a/drivers/platform/x86/amd/pmf/spc.c
> +++ b/drivers/platform/x86/amd/pmf/spc.c
> @@ -249,10 +249,11 @@ static int amd_pmf_get_battery_prop(enum power_supply_property prop)
>   			continue;
>   
>   		ret = power_supply_get_property(psy, prop, &value);
> -		if (ret) {
> -			power_supply_put(psy);
> +		power_supply_put(psy);
> +		if (ret)
>   			return ret;
> -		}
> +
> +		break;
>   	}
>   
>   	return value.intval;


      reply	other threads:[~2026-09-17 18:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 14:01 Wentao Liang
2026-09-17 18:02 ` Mario Limonciello [this message]

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=55c9bb7f-33f0-4fb0-8fac-69d5660ac1bc@kernel.org \
    --to=superm1@kernel.org \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=vulab@iscas.ac.cn \
    /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®