Re: [PATCH] platform/x86/amd/pmf: Fix power_supply refcount leak in amd_pmf_get_battery_prop()

From: Ilpo Järvinen

Date: Mon Oct 05 2026 - 14:04:03 EST


On Wed, 02 Sep 2026 16:02:12 -0500, Jack Boykin wrote:

> power_supply_get_by_name() takes a reference that is only dropped on
> the error path. On success it leaks, five times per policy evaluation.
> Unregistering the battery later trips the use_cnt WARN_ON in
> power_supply_unregister() and never frees it.
>
> While here, return -ENODEV instead of an uninitialised 'value' when
> no battery matches, and stop at the first supply found rather than
> letting the last one in the table win.
>
> [...]

Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.

FYI [if applicable to your patch], as per Linus' policy change, also
fixes are mostly routed through for-next unless the fix is for a
commit introduced in the most recent cycle or is clearly a regression
fix.

The list of commits applied:
[1/1] platform/x86/amd/pmf: Fix power_supply refcount leak in amd_pmf_get_battery_prop()
commit: 6676654ebfc858cfc416b44d7687ccc6bfe0b021

--
i.