linux/drivers/base
Gui-Dong Han e84e1451a0 PM: sleep: wakeirq: harden dev_pm_clear_wake_irq() against races
[ Upstream commit 5c9ecd8e64 ]

dev_pm_clear_wake_irq() currently uses a dangerous pattern where
dev->power.wakeirq is read and checked for NULL outside the lock.
If two callers invoke this function concurrently, both might see
a valid pointer and proceed. This could result in a double-free
when the second caller acquires the lock and tries to release the
same object.

Address this by removing the lockless check of dev->power.wakeirq.
Instead, acquire dev->power.lock immediately to ensure the check and
the subsequent operations are atomic. If dev->power.wakeirq is NULL
under the lock, simply unlock and return. This guarantees that
concurrent calls cannot race to free the same object.

Based on a quick scan of current users, I did not find an actual bug as
drivers seem to rely on their own synchronization. However, since
asynchronous usage patterns exist (e.g., in
drivers/net/wireless/ti/wlcore), I believe a race is theoretically
possible if the API is used less carefully in the future. This change
hardens the API to be robust against such cases.

Fixes: 4990d4fe32 ("PM / Wakeirq: Add automated device wake IRQ handling")
Signed-off-by: Gui-Dong Han <hanguidong02@gmail.com>
Link: https://patch.msgid.link/20260203031943.1924-1-hanguidong02@gmail.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-03-04 07:19:23 -05:00
..
firmware_loader firmware_loader: Block path traversal 2024-10-17 15:11:12 +02:00
power PM: sleep: wakeirq: harden dev_pm_clear_wake_irq() against races 2026-03-04 07:19:23 -05:00
regmap regmap: Fix race condition in hwspinlock irqsave routine 2026-02-06 16:41:54 +01:00
test driver core: test_async: fix an error code 2023-09-19 12:22:45 +02:00
arch_numa.c memblock: drop memblock_free_early_nid() and memblock_free_early() 2025-03-13 12:50:07 +01:00
arch_topology.c arch_topology: Fix incorrect error check in topology_parse_cpu_capacity() 2025-10-29 14:03:15 +01:00
attribute_container.c driver core: attribute_container: fix W=1 warnings 2021-05-14 13:37:10 +02:00
auxiliary.c Merge 5.14-rc3 into driver-core-next 2021-07-27 09:22:08 +02:00
base.h software nodes: Split software_node_notify() 2021-07-16 19:17:05 +02:00
bus.c driver core: bus: Fix double free in driver API bus_register() 2024-12-14 19:51:14 +01:00
cacheinfo.c cacheinfo: clear cache_leaves(cpu) in free_cache_attributes() 2021-07-21 17:29:40 +02:00
class.c class: fix possible memory leak in __class_register() 2022-12-31 13:14:27 +01:00
component.c drivers: base: component: fix memory leak with using debugfs_lookup() 2023-03-11 13:57:38 +01:00
container.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
core.c driver core: Introduce device_find_any_child() helper 2024-12-14 19:50:59 +01:00
cpu.c x86/vmscape: Enable the mitigation 2025-09-11 17:17:17 +02:00
dd.c driver core: Release all resources during unbind before updating device links 2023-11-28 16:56:36 +00:00
devcoredump.c devcoredump: Fix circular locking dependency with devcd->mutex. 2025-10-29 14:03:15 +01:00
devres.c drivers: base: devres: Allow to release group on device release 2025-05-02 07:43:57 +02:00
devtmpfs.c devtmpfs regression fix: reconfigure on each mount 2022-01-20 09:13:13 +01:00
driver.c driver: platform: Add helper for safer setting of driver_override 2023-11-08 17:26:43 +01:00
firmware.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
hypervisor.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
init.c init: Initialize noop_backing_dev_info early 2022-06-22 14:22:02 +02:00
isa.c bus: Make remove callback return void 2021-07-21 11:53:42 +02:00
Kconfig RISC-V Patches for the 5.12 Merge Window 2021-02-26 10:28:35 -08:00
Makefile devres: Enable trace events 2021-06-15 17:14:36 +02:00
map.c driver: base: Prefer unsigned int to bare use of unsigned 2021-07-21 17:30:09 +02:00
memory.c mm/hwpoison: avoid the impact of hwpoison_filter() return value on mce handler 2022-07-12 16:35:05 +02:00
module.c Revert "driver core: Fix uevent_show() vs driver detach race" 2024-11-08 16:25:54 +01:00
node.c drivers/base/node: fix double free in register_one_node() 2025-10-19 16:21:37 +02:00
pinctrl.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
platform-msi.c platform-msi: Add ABI to show msi_irqs of platform devices 2021-08-24 09:16:20 +02:00
platform.c driver: platform: Add helper for safer setting of driver_override 2023-11-08 17:26:43 +01:00
property.c device property: Add fwnode_irq_get_byname 2024-10-17 15:11:43 +02:00
soc.c soc: fix comment for freeing soc_dev_attr 2020-12-09 19:46:31 +01:00
swnode.c software node: Correct a OOB check in software_node_get_reference_args() 2025-06-27 11:05:32 +01:00
syscore.c syscore: Use pm_pr_dbg() for syscore_{suspend,resume}() 2020-09-08 13:32:06 +02:00
topology.c topology: Keep the cpumask unchanged when printing cpumap 2025-01-23 17:15:53 +01:00
trace.c devres: Enable trace events 2021-06-15 17:14:36 +02:00
trace.h devres: Enable trace events 2021-06-15 17:14:36 +02:00
transport_class.c drivers: base: transport_class: fix resource leak when transport_add_device() fails 2023-03-10 09:39:39 +01:00