Skip to content

Commit 989fa51

Browse files
committed
Bluetooth: hci_core: Disable works on hci_unregister_dev
This make use of disable_work_* on hci_unregister_dev since the hci_dev is about to be freed new submissions are not disarable. Fixes: 0d151a1 ("Bluetooth: hci_core: cancel all works upon hci_unregister_dev()") Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 6e62807 commit 989fa51

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

net/bluetooth/hci_core.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,12 +1644,12 @@ void hci_adv_instances_clear(struct hci_dev *hdev)
16441644
struct adv_info *adv_instance, *n;
16451645

16461646
if (hdev->adv_instance_timeout) {
1647-
cancel_delayed_work(&hdev->adv_instance_expire);
1647+
disable_delayed_work(&hdev->adv_instance_expire);
16481648
hdev->adv_instance_timeout = 0;
16491649
}
16501650

16511651
list_for_each_entry_safe(adv_instance, n, &hdev->adv_instances, list) {
1652-
cancel_delayed_work_sync(&adv_instance->rpa_expired_cb);
1652+
disable_delayed_work_sync(&adv_instance->rpa_expired_cb);
16531653
list_del(&adv_instance->list);
16541654
kfree(adv_instance);
16551655
}
@@ -2685,11 +2685,11 @@ void hci_unregister_dev(struct hci_dev *hdev)
26852685
list_del(&hdev->list);
26862686
write_unlock(&hci_dev_list_lock);
26872687

2688-
cancel_work_sync(&hdev->rx_work);
2689-
cancel_work_sync(&hdev->cmd_work);
2690-
cancel_work_sync(&hdev->tx_work);
2691-
cancel_work_sync(&hdev->power_on);
2692-
cancel_work_sync(&hdev->error_reset);
2688+
disable_work_sync(&hdev->rx_work);
2689+
disable_work_sync(&hdev->cmd_work);
2690+
disable_work_sync(&hdev->tx_work);
2691+
disable_work_sync(&hdev->power_on);
2692+
disable_work_sync(&hdev->error_reset);
26932693

26942694
hci_cmd_sync_clear(hdev);
26952695

@@ -2796,8 +2796,14 @@ static void hci_cancel_cmd_sync(struct hci_dev *hdev, int err)
27962796
{
27972797
bt_dev_dbg(hdev, "err 0x%2.2x", err);
27982798

2799-
cancel_delayed_work_sync(&hdev->cmd_timer);
2800-
cancel_delayed_work_sync(&hdev->ncmd_timer);
2799+
if (hci_dev_test_flag(hdev, HCI_UNREGISTER)) {
2800+
disable_delayed_work_sync(&hdev->cmd_timer);
2801+
disable_delayed_work_sync(&hdev->ncmd_timer);
2802+
} else {
2803+
cancel_delayed_work_sync(&hdev->cmd_timer);
2804+
cancel_delayed_work_sync(&hdev->ncmd_timer);
2805+
}
2806+
28012807
atomic_set(&hdev->cmd_cnt, 1);
28022808

28032809
hci_cmd_sync_cancel_sync(hdev, err);

net/bluetooth/hci_sync.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5131,9 +5131,15 @@ int hci_dev_close_sync(struct hci_dev *hdev)
51315131

51325132
bt_dev_dbg(hdev, "");
51335133

5134-
cancel_delayed_work(&hdev->power_off);
5135-
cancel_delayed_work(&hdev->ncmd_timer);
5136-
cancel_delayed_work(&hdev->le_scan_disable);
5134+
if (hci_dev_test_flag(hdev, HCI_UNREGISTER)) {
5135+
disable_delayed_work(&hdev->power_off);
5136+
disable_delayed_work(&hdev->ncmd_timer);
5137+
disable_delayed_work(&hdev->le_scan_disable);
5138+
} else {
5139+
cancel_delayed_work(&hdev->power_off);
5140+
cancel_delayed_work(&hdev->ncmd_timer);
5141+
cancel_delayed_work(&hdev->le_scan_disable);
5142+
}
51375143

51385144
hci_cmd_sync_cancel_sync(hdev, ENODEV);
51395145

0 commit comments

Comments
 (0)