* [PATCH] platform/x86/amd/pmf: Fix power supply leak in amd_pmf_get_battery_prop()
@ 2026-09-17 14:01 Wentao Liang
2026-09-17 18:02 ` Mario Limonciello
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-17 14:01 UTC (permalink / raw)
To: Shyam-sundar.S-k
Cc: hansg, ilpo.jarvinen, linux-kernel, mario.limonciello,
platform-driver-x86, Wentao Liang, stable
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>
---
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;
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] platform/x86/amd/pmf: Fix power supply leak in amd_pmf_get_battery_prop()
2026-09-17 14:01 [PATCH] platform/x86/amd/pmf: Fix power supply leak in amd_pmf_get_battery_prop() Wentao Liang
@ 2026-09-17 18:02 ` Mario Limonciello
0 siblings, 0 replies; 2+ messages in thread
From: Mario Limonciello @ 2026-09-17 18:02 UTC (permalink / raw)
To: Wentao Liang, Shyam-sundar.S-k
Cc: hansg, ilpo.jarvinen, linux-kernel, platform-driver-x86, stable
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;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-17 18:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 14:01 [PATCH] platform/x86/amd/pmf: Fix power supply leak in amd_pmf_get_battery_prop() Wentao Liang
2026-09-17 18:02 ` Mario Limonciello
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®