]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Bluetooth: hci_event: Fix setting DISCOVERY_FINDING for passive scanning
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 25 Jul 2024 22:28:08 +0000 (18:28 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 11 Aug 2024 10:58:01 +0000 (12:58 +0200)
commit df3d6a3e01fd82cb74b6bb309f7be71e728a3448 upstream.

DISCOVERY_FINDING shall only be set for active scanning as passive
scanning is not meant to generate MGMT Device Found events causing
discovering state to go out of sync since userspace would believe it
is discovering when in fact it is just passive scanning.

Cc: stable@vger.kernel.org
Link: https://bugzilla.kernel.org/show_bug.cgi?id=219088
Fixes: 2e2515c1ba38 ("Bluetooth: hci_event: Set DISCOVERY_FINDING on SCAN_ENABLED")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/bluetooth/hci_core.c
net/bluetooth/hci_event.c

index 7ae118a6d947b8d15f0ef413d23c080edec38edb..6ecb110bf46bc2efb204c82fae8413bbc5e147c3 100644 (file)
@@ -120,13 +120,6 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state)
        case DISCOVERY_STARTING:
                break;
        case DISCOVERY_FINDING:
-               /* If discovery was not started then it was initiated by the
-                * MGMT interface so no MGMT event shall be generated either
-                */
-               if (old_state != DISCOVERY_STARTING) {
-                       hdev->discovery.state = old_state;
-                       return;
-               }
                mgmt_discovering(hdev, 1);
                break;
        case DISCOVERY_RESOLVING:
index 4611a67d7dcc34a2e05f913e00d577593e9877a0..a78f6d706cd43edbe495c0e1865a4372a3f25b6b 100644 (file)
@@ -1722,9 +1722,10 @@ static void le_set_scan_enable_complete(struct hci_dev *hdev, u8 enable)
        switch (enable) {
        case LE_SCAN_ENABLE:
                hci_dev_set_flag(hdev, HCI_LE_SCAN);
-               if (hdev->le_scan_type == LE_SCAN_ACTIVE)
+               if (hdev->le_scan_type == LE_SCAN_ACTIVE) {
                        clear_pending_adv_report(hdev);
-               hci_discovery_set_state(hdev, DISCOVERY_FINDING);
+                       hci_discovery_set_state(hdev, DISCOVERY_FINDING);
+               }
                break;
 
        case LE_SCAN_DISABLE: