Bluetooth: hci_core: fix init for HCI_USER_CHANNEL
authorMattijs Korpershoek <mkorpershoek@baylibre.com>
Thu, 17 Oct 2019 03:20:39 +0000 (20:20 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 17 Oct 2019 05:10:49 +0000 (07:10 +0200)
During the setup() stage, HCI device drivers expect the chip to
acknowledge its setup() completion via vendor specific frames.

If userspace opens() such HCI device in HCI_USER_CHANNEL [1] mode,
the vendor specific frames are never tranmitted to the driver, as
they are filtered in hci_rx_work().

Allow HCI devices which operate in HCI_USER_CHANNEL mode to receive
frames if the HCI device is is HCI_INIT state.

[1] https://www.spinics.net/lists/linux-bluetooth/msg37345.html

Fixes: 23500189d7e0 ("Bluetooth: Introduce new HCI socket channel for user operation")
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/hci_core.c

index b2559d4..0cc9ce9 100644 (file)
@@ -4440,7 +4440,14 @@ static void hci_rx_work(struct work_struct *work)
                        hci_send_to_sock(hdev, skb);
                }
 
-               if (hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) {
+               /* If the device has been opened in HCI_USER_CHANNEL,
+                * the userspace has exclusive access to device.
+                * When device is HCI_INIT, we still need to process
+                * the data packets to the driver in order
+                * to complete its setup().
+                */
+               if (hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
+                   !test_bit(HCI_INIT, &hdev->flags)) {
                        kfree_skb(skb);
                        continue;
                }