diff options
| author | Hang Nan <2122295973@qq.com> | 2026-10-18 00:39:05 +0200 |
|---|---|---|
| committer | Sebastian Reichel <sebastian.reichel@collabora.com> | 2026-10-18 00:55:38 +0200 |
| commit | 9f7f7a85945156d5c7626390a8c46d43d5159abc (patch) | |
| tree | 2b2149afdabecc8f51c26dac84090ab5e292eb0c /include/linux/workqueue_api.h | |
| parent | 6a559552107ab6b470af0cb5e6aab3aad17c19cc (diff) | |
power_supply: serialize property access with unregister
Extend 5b4bd13e0552 ("power: supply: core: prevent unregistering a power
supply while a callback runs") fix to also cover the get and set property
hooks.
This has been tested with a small out-of-tree module registering a
supply whose get property function caches its drv_data pointer and then
sleeps 300 ms, while the module's main thread calls power_supply_unregister()
and then frees that drv_data:
unpatched: unregister() returns after 78 us
callback then reads drv_data 0x6b6b6b6b (slub poison)
=> the driver callback read freed memory
patched: unregister() returns after 302549 us (the 300 ms callback)
callback then reads drv_data 0x12345678 (intact)
=> power_supply_unregister() waits for the in-flight callback
The lock is taken in the wrappers rather than in the helper so that the
_direct() variants stay lockless: a caller that has to read its own
supply from within a callback uses those, and rwsem read locking is not
recursive once a writer is waiting.
Fixes: bc1540561c9e ("power_supply: Add API for safe access of power supply function attrs")
Fixes: 5b4bd13e0552 ("power: supply: core: prevent unregistering a power supply while a callback runs")
Signed-off-by: Hang Nan <2122295973@qq.com>
[massively trim down AI commit message and comments]
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'include/linux/workqueue_api.h')
0 files changed, 0 insertions, 0 deletions
