[PATCH 0/5] power: supply: Fix probe time race against driver teardown and battery parsing
From: Alexey Charkov
Date: Mon Sep 07 2026 - 11:06:30 EST
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 <alchark@xxxxxxxxxxx>
---
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 supply
drivers/power/supply/bq257xx_charger.c | 56 ++++++++------
drivers/power/supply/power_supply_core.c | 128 +++++++++++++++++++++++--------
include/linux/power_supply.h | 13 ++++
3 files changed, 143 insertions(+), 54 deletions(-)
---
base-commit: af5f12805e5cefa4fe68d6127c7e1fb78cd5535c
change-id: 20260907-bq257xx-init-ff03beb07c36
Best regards,
--
Alexey Charkov <alchark@xxxxxxxxxxx>