Skip to content

Commit 0d151a1

Browse files
Tetsuo HandaVudentz
authored andcommitted
Bluetooth: hci_core: cancel all works upon hci_unregister_dev()
syzbot is reporting that calling hci_release_dev() from hci_error_reset() due to hci_dev_put() from hci_error_reset() can cause deadlock at destroy_workqueue(), for hci_error_reset() is called from hdev->req_workqueue which destroy_workqueue() needs to flush. We need to make sure that hdev->{rx_work,cmd_work,tx_work} which are queued into hdev->workqueue and hdev->{power_on,error_reset} which are queued into hdev->req_workqueue are no longer running by the moment destroy_workqueue(hdev->workqueue); destroy_workqueue(hdev->req_workqueue); are called from hci_release_dev(). Call cancel_work_sync() on these work items from hci_unregister_dev() as soon as hdev->list is removed from hci_dev_list. Reported-by: syzbot <[email protected]> Closes: https://syzkaller.appspot.com/bug?extid=da0a9c9721e36db712e8 Signed-off-by: Tetsuo Handa <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 88e7223 commit 0d151a1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

net/bluetooth/hci_core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,7 +2751,11 @@ void hci_unregister_dev(struct hci_dev *hdev)
27512751
list_del(&hdev->list);
27522752
write_unlock(&hci_dev_list_lock);
27532753

2754+
cancel_work_sync(&hdev->rx_work);
2755+
cancel_work_sync(&hdev->cmd_work);
2756+
cancel_work_sync(&hdev->tx_work);
27542757
cancel_work_sync(&hdev->power_on);
2758+
cancel_work_sync(&hdev->error_reset);
27552759

27562760
hci_cmd_sync_clear(hdev);
27572761

0 commit comments

Comments
 (0)