Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit a9f6a19b authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Sebastian Reichel
Browse files

power_supply: Use wrappers to avoid races when registering power supply



Use wrappers over get_property() and set_property() internally in power
supply and for sysfs interface. The wrappers provide safe access if
power supply is not yet registered or t is being destroyed.

In case of syfs the theoretical race could happen between ending of
driver's probe and parallel sysfs access:
some_driver_probe()                    userspace
====================================   ===========================
  drv->psy = power_supply_register()
    device_add()
      sysfs entries are created
    atomic_inc(&psy->use_cnt);
                                       store on sysfs attributes
                                         drv->set_property()
                                           dereference of drv->psy
  drv->psy = returned psy;

For leds the race could happen between power supply being destroyed and
ongoing power_supply_changed_work().

Signed-off-by: default avatarKrzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent 9f6cd98f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment