Bluetooth: Simplify request cleanup code
authorJohan Hedberg <johan.hedberg@intel.com>
Thu, 12 Nov 2015 13:15:00 +0000 (15:15 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 19 Nov 2015 16:50:32 +0000 (17:50 +0100)
The hci_req_sync_cancel() is just as much related to the request
cleanup as hci_request_cancel_all() is. Just move the former into the
latter and do the cleanup from a single place in hci_dev_do_close().
The important thing is to avoid deadlocks by holding the req_sync
lock: previously hci_request_cancel_all was done right after releasing
the lock and with this patch it's right before taking it.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/hci_core.c
net/bluetooth/hci_request.c

index fb618d6bcded5b540b613d8fab35a2fc516d666b..63fd31d7b27a6b020dee92b84f13eacb32a59767 100644 (file)
@@ -1523,7 +1523,7 @@ int hci_dev_do_close(struct hci_dev *hdev)
 
        cancel_delayed_work(&hdev->power_off);
 
-       hci_req_sync_cancel(hdev, ENODEV);
+       hci_request_cancel_all(hdev);
        hci_req_sync_lock(hdev);
 
        if (!test_and_clear_bit(HCI_UP, &hdev->flags)) {
@@ -1625,8 +1625,6 @@ int hci_dev_do_close(struct hci_dev *hdev)
 
        hci_req_sync_unlock(hdev);
 
-       hci_request_cancel_all(hdev);
-
        hci_dev_put(hdev);
        return 0;
 }
index e8345d8106b5336c8f9085dbab9b7def87241ebb..76bd912be9fe16ea3abf862e9568f449437db571 100644 (file)
@@ -1270,6 +1270,8 @@ void hci_request_setup(struct hci_dev *hdev)
 
 void hci_request_cancel_all(struct hci_dev *hdev)
 {
+       hci_req_sync_cancel(hdev, ENODEV);
+
        cancel_work_sync(&hdev->discov_update);
        cancel_work_sync(&hdev->bg_scan_update);
        cancel_delayed_work_sync(&hdev->le_scan_disable);