Bluetooth: Simplify request cleanup code
Subsystems (2)
PATCH 1/1 Bluetooth: Simplify request cleanup code
From: Johan Hedberg <[email protected]>
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.
--- net/bluetooth/hci_core.c | 4 +--- net/bluetooth/hci_request.c | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-)
net/bluetooth/hci_core.c +1 -3
@@ -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 ; }
net/bluetooth/hci_request.c +2 -0
@@ -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);
Signature · 1 line
2.5.0
Marcel Holtmann
maintainerHi Johan,
Quoted 7 lines
The
hci_req_sync_cancel()is just as much related to the request cleanup ashci_request_cancel_all()is. Just move the former into the latter and do the cleanup from a single place inhci_dev_do_close(). The important thing is to avoid deadlocks by holding thereq_sync
lock: previouslyhci_request_cancel_allwas done right after releasing the lock and with this patch it's right before taking it.
Quoted 5 lines
Signed-off-by Johan Hedberg <[email protected]>---
net/bluetooth/hci_core.c| 4 +---net/bluetooth/hci_request.c| 2 ++2 files changed, 3 insertions(+), 3 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel