Re: [PATCH v2] power: supply: charger-manager: register regulators before exposing sysfs

Sebastian Reichel <[email protected]>
Newsgroups org.kernel.vger.linux-pm,org.kernel.vger.linux-kernel,org.kernel.vger.stable
Message-ID <178544939069.241335.6930700242897058437.b4-ty@b4>
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 <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.