Re: [PATCH v2] power: supply: charger-manager: register regulators before exposing sysfs
From: Sebastian Reichel
Date: Thu Jul 30 2026 - 18:10:11 EST
On Tue, 28 Jul 2026 03:01:23 +0000, Fan Wu wrote:
> charger_manager_remove() and the err_reg_extcon probe error path free each
> charger regulator with regulator_put() before tearing down the power_supply
> sysfs entries (power_supply_unregister()). charger_manager_remove() also
> calls try_charger_enable(cm, false) after the regulator_put() loop. A
> concurrent write to a charger's externally_control sysfs attribute that
> lands between regulator_put() and power_supply_unregister() can run
> charger_externally_control_store() and call try_charger_enable(), which,
> when charging is enabled, dereferences the already-freed consumer handle.
> When charging is enabled, try_charger_enable(cm, false) in .remove() also
> dereferences the freed handles directly. Both leave use-after-free windows.
> Symmetrically, probe registers the sysfs entries (power_supply_register)
> before acquiring the regulators (regulator_get, inside
> charger_manager_register_extcon), so userspace can reach externally_control
> before the regulators are available.
>
> [...]
Applied, thanks!
[1/1] power: supply: charger-manager: register regulators before exposing sysfs
commit: c57cb36f76eb7ced45f57af1a890d8f3a6d76342
Best regards,
--
Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxx>