[PATCH v2 0/3] Bluetooth: Fix work queued while hci_dev_close_sync() drains

From: Jeremy Dean Clifton

Date: Mon Nov 16 2026 - 21:35:56 EST


syzbot reports "workqueue: cannot queue hci_conn_timeout on wq hci0"
from hci_conn_drop() while hci_dev_close_sync() runs drain_workqueue().

v1 made hci_conn_drop() skip queueing disc_work while
HCI_CMD_DRAIN_WORKQUEUE is set. Sashiko pointed out that this misses
two cases: a connection delayed work whose timer was armed before close
can still fire during the drain, and a connection created after
hci_conn_hash_flush() is never deleted.

v2 drops the hci_conn_drop() change and fixes the cause instead:

- Patch 1 frees the unset handle when __hci_conn_add() fails. The
leak already exists on the -ECONNREFUSED and -ENOMEM paths, and
patch 2 adds another error return. Sashiko found it while
reviewing patch 2.
- Patch 2 makes __hci_conn_add() refuse new connections once HCI_UP
is cleared, and asserts that hdev->lock is held. I checked every
caller and all of them hold the lock.
- Patch 3 disables the per-connection delayed works before
drain_workqueue(), so neither the timers nor hci_conn_drop() can
queue them during the drain. It depends on patch 2: without it, a
connection added after the walk could still queue its works.

Testing: built on arm64 against bluetooth-next (da3cc02). With KASAN
and lockdep enabled, the syzbot C reproducer was run under QEMU/HVF
(2 vCPUs), one fresh boot per run:

without this series: 7/12 runs hit "workqueue: cannot queue
hci_conn_timeout on wq hci0"
with this series: 0/12 runs, no other warnings, KASAN or
lockdep reports

Sashiko reviewed the series locally with no critical, high or medium
findings.

Claude (Opus 5.5) helped analyze the race, draft the patches and audit
the __hci_conn_add() callers for hdev->lock. Sashiko reviewed v1 and
this series.

Changes in v2:
- Drop the hci_conn_drop() change.
- Add patches 1 and 2.
- Disable the connection works before the drain (patch 3).
- Fixes tag changed from 525daaea459f to 76727c02c1e1.

v1: https://lore.kernel.org/all/20261020145320.115333-1-deaner92@xxxxxxxxx/

Jeremy Dean Clifton (3):
Bluetooth: hci_conn: Free the unset handle when adding a connection
fails
Bluetooth: hci_conn: Refuse new connections once HCI_UP is cleared
Bluetooth: hci_sync: Disable connection works before draining

net/bluetooth/hci_conn.c | 16 +++++++++++++++-
net/bluetooth/hci_sync.c | 17 +++++++++++++++++
2 files changed, 32 insertions(+), 1 deletion(-)

--
2.43.0