* [PATCH] Bluetooth: hci_core: Check HCI_CMD_DRAIN_WORKQUEUE in hci_cmd_timeout()
@ 2026-10-28 8:33 Yang Guikun
2026-10-28 11:28 ` bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Yang Guikun @ 2026-10-28 8:33 UTC (permalink / raw)
To: marcel, luiz.dentz, linux-bluetooth; +Cc: linux-kernel
Bluetooth: hci_core: Check HCI_CMD_DRAIN_WORKQUEUE in hci_cmd_timeout()
hci_cmd_timeout() runs from timer softirq and queues cmd_work
unconditionally. If the timer expires while hci_dev_close_sync() is
in drain_workqueue(), __queue_work() sees __WQ_DRAINING and warns:
workqueue: cannot queue hci_cmd_timeout on wq hci0
cmd_timer is cancelled only after drain_workqueue(), so the window
between them is reachable when an HCI device with a command outstanding
is powered off via rfkill.
hci_cmd_work() and handle_cmd_cnt_and_timer() already skip queuing when
HCI_CMD_DRAIN_WORKQUEUE is set; hci_cmd_timeout() is the remaining
unchecked producer.
Fixes: 525daaea459f ("Bluetooth: hci_sync: Set HCI_CMD_DRAIN_WORKQUEUE during device close")
Signed-off-by: Yang Guikun <yangguikun19@qq.com>
---
net/bluetooth/hci_core.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 209244fd9391..3333333333333 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1441,7 +1441,10 @@ static void hci_cmd_timeout(struct work_struct *work)
hdev->reset(hdev);
atomic_set(&hdev->cmd_cnt, 1);
- queue_work(hdev->workqueue, &hdev->cmd_work);
+ rcu_read_lock();
+ if (!hci_dev_test_flag(hdev, HCI_CMD_DRAIN_WORKQUEUE))
+ queue_work(hdev->workqueue, &hdev->cmd_work);
+ rcu_read_unlock();
}
/* HCI ncmd timer function */
--
2.39.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-28 11:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-28 8:33 [PATCH] Bluetooth: hci_core: Check HCI_CMD_DRAIN_WORKQUEUE in hci_cmd_timeout() Yang Guikun
2026-10-28 11:28 ` bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox