* [PATCH wireless] rfkill: initialize work items before publishing rfkill device
@ 2026-11-25 22:16 Elkin Cruz
0 siblings, 0 replies; only message in thread
From: Elkin Cruz @ 2026-11-25 22:16 UTC (permalink / raw)
To: Johannes Berg
Cc: linux-wireless, linux-kernel, llvm, irogers, Elkin Cruz, stable
rfkill_register() added the device to rfkill_list, called device_add(),
and set rfkill->registered = true before initializing poll_work,
uevent_work, and sync_work. Because rfkill_set_states() and
rfkill_set_hw_state_reason() only serialize on rfkill->lock and schedule
uevent_work once rfkill->registered is true, a concurrent state update
can race with INIT_WORK().
Initialize all three work structs prior to publishing the device.
Fixes: 19d337dff95c ("rfkill: rewrite")
Cc: stable@vger.kernel.org
Signed-off-by: Elkin Cruz <elkin@google.com>
---
I am trying out new Clang static analysis checks for kernel bug
classes, and they flagged this code as possibly buggy. The findings
were triaged/fixed and commit descriptions were drafted with help of AI,
then checked against linux-next (not runtime-tested on hardware).
Thanks,
Elkin
net/rfkill/core.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index 9e143c4bfe6a..071beb249b4c 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -1095,6 +1095,10 @@ int __must_check rfkill_register(struct rfkill *rfkill)
dev_set_name(dev, "rfkill%lu", rfkill_no);
rfkill_no++;
+ INIT_DELAYED_WORK(&rfkill->poll_work, rfkill_poll);
+ INIT_WORK(&rfkill->uevent_work, rfkill_uevent_work);
+ INIT_WORK(&rfkill->sync_work, rfkill_sync_work);
+
list_add_tail(&rfkill->node, &rfkill_list);
error = device_add(dev);
@@ -1107,10 +1111,6 @@ int __must_check rfkill_register(struct rfkill *rfkill)
rfkill->registered = true;
- INIT_DELAYED_WORK(&rfkill->poll_work, rfkill_poll);
- INIT_WORK(&rfkill->uevent_work, rfkill_uevent_work);
- INIT_WORK(&rfkill->sync_work, rfkill_sync_work);
-
if (rfkill->ops->poll)
queue_delayed_work(system_power_efficient_wq,
&rfkill->poll_work,
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-25 22:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 22:16 [PATCH wireless] rfkill: initialize work items before publishing rfkill device Elkin Cruz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®