Skip to content

Commit 04d9741

Browse files
jwrdegoedesre
authored andcommitted
power: supply: Use power_supply_external_power_changed() in __power_supply_changed_work()
The power-supply core is designed so that power-supply driver callbacks such as get_property() and external_power_changed() will not be called until the power-supply's parent driver's probe() function has completed. There is a race where power_supply_changed() can be called for a supplier of a power-supply which is being probed after the device_add() in __power_supply_register() but before the parent driver's probe() function has completed. Hitting this race breaks the power-supply core's design to not call power-supply driver callbacks before probe() completion. This problem is caused by __power_supply_changed_work() calling the external_power_changed() directly rather then going through the power_supply_external_power_changed() helper which correcly checks psy->use_cnt . Switch to using power_supply_external_power_changed() to fix this race. Signed-off-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 2109680 commit 04d9741

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/power/supply/power_supply_core.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,8 @@ static int __power_supply_changed_work(struct power_supply *pst, void *data)
7070
{
7171
struct power_supply *psy = data;
7272

73-
if (__power_supply_is_supplied_by(psy, pst)) {
74-
if (pst->desc->external_power_changed)
75-
pst->desc->external_power_changed(pst);
76-
}
73+
if (__power_supply_is_supplied_by(psy, pst))
74+
power_supply_external_power_changed(pst);
7775

7876
return 0;
7977
}

0 commit comments

Comments
 (0)