Bluetooth: Fix trying to disable scanning twice
authorJohan Hedberg <johan.hedberg@intel.com>
Fri, 28 Feb 2014 18:26:12 +0000 (20:26 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 28 Feb 2014 18:28:16 +0000 (10:28 -0800)
The discovery process has a timer for disabling scanning, however
scanning might be disabled through other means too like the auto-connect
process.  We should therefore ensure that the timer is never active
after sending a HCI command to disable scanning.

There was some existing code in stop_scan_complete trying to avoid the
timer when a connect request interrupts a discovery procedure, but the
other way around was not covered. This patch covers both scenarios by
canceling the timer as soon as we get a successful command complete for
the disabling HCI command.

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

index 7e47e4240c95be6b20d0d9a5848c79fe67840634..5330fcfde93dcae71c38c0131ec81f0e5cbd6b5b 100644 (file)
@@ -628,7 +628,6 @@ static void stop_scan_complete(struct hci_dev *hdev, u8 status)
        /* Since we may have prematurely stopped discovery procedure, we should
         * update discovery state.
         */
-       cancel_delayed_work(&hdev->le_scan_disable);
        hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
 
        hci_req_init(&req, hdev);
index a1075c713a9d817c162a876cd165cfb9e6069e6a..e3335b03c9923145a1b92216f3958bc660f07b03 100644 (file)
@@ -1018,6 +1018,11 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
                break;
 
        case LE_SCAN_DISABLE:
+               /* Cancel this timer so that we don't try to disable scanning
+                * when it's already disabled.
+                */
+               cancel_delayed_work(&hdev->le_scan_disable);
+
                clear_bit(HCI_LE_SCAN, &hdev->dev_flags);
                break;