Re: [PATCH 0/5] power: supply: Fix probe time race against driver teardown and battery parsing
From: Alexey Charkov <hidden>
Date: 2026-09-07 17:24:58
Also in:
lkml
On Mon, Sep 7, 2026 at 7:01 PM Alexey Charkov [off-list ref] wrote:
If a bus holding the battery-equipped power supply goes down right after
it registered, it leads to massive fireworks as the driver starts to tear
down its resources while callers from other contexts are already eager to
process events using this driver's callbacks (and their private data).
In current power supply core it's further aggravated by the fact that the
battery parsing code expects a psy struct from the caller, which is only
available once the device has been registered, so the device gets
registered with its hardware constraints (e.g. charging current) not yet
fully filled in.
Fix the former by preventing the unregistration of the psy device before
its callbacks complete, and the latter by providing a battery parsing
helper which doesn't require a psy struct from the caller (as it doesn't
strictly need one).
While here, fix up these and other adjacent issues in bq257xx where all of
it was discovered.
Signed-off-by: Alexey Charkov <redacted>
---
Alexey Charkov (5):
power: supply: core: prevent unregistering a power supply while a callback runs
power: supply: core: Allow getting battery info before psy is registered
power: supply: bq257xx: Don't ignore errors from bq257xx_get_state()
power: supply: bq257xx: Use psy directly instead of driver data
power: supply: bq257xx: Parse battery info before registering power supplySashiko gave valuable feedback on this series [1], which I'll address in v2 - except for the part where it thought up a non-USB supply for bq257xx, which the driver explicitly doesn't support. [1] https://sashiko.dev/#/patchset/20260907-bq257xx-init-v1-0-1a08b29e1a68%40flipper.net Best regards, Alexey