]> www.infradead.org Git - users/willy/xarray.git/commit
power: supply: Use power_supply_external_power_changed() in __power_supply_changed_work()
authorHans de Goede <hdegoede@redhat.com>
Sun, 15 Dec 2024 17:21:24 +0000 (18:21 +0100)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Thu, 19 Dec 2024 23:36:05 +0000 (00:36 +0100)
commit04d9741493e7a1d17d2109f4c9ea21f3314666b4
tree4feba54e728726511388457e9a29727c117ef318
parent21096800c5ac634a9fbbac21505bfd798163b390
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 <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20241215172133.178460-2-hdegoede@redhat.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/power_supply_core.c