Created
February 7, 2021 00:12
-
-
Save t3hk0d3/543027dce67a6753e6ee28abb7aaf2c9 to your computer and use it in GitHub Desktop.
Patch to fix broken fake-CSR BT dongle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c | |
index 80468745d..953eba56d 100644 | |
--- a/drivers/bluetooth/btusb.c | |
+++ b/drivers/bluetooth/btusb.c | |
@@ -1768,6 +1768,7 @@ static int btusb_setup_csr(struct hci_dev *hdev) | |
struct hci_rp_read_local_version *rp; | |
struct sk_buff *skb; | |
bool is_fake = false; | |
BT_DBG("%s", hdev->name); | |
@@ -1856,6 +1857,52 @@ static int btusb_setup_csr(struct hci_dev *hdev) | |
*/ | |
clear_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks); | |
clear_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); | |
+ | |
+ if (bcdDevice == 0x8891 && | |
+ le16_to_cpu(rp->lmp_subver) == 0x22bb && | |
+ le16_to_cpu(rp->hci_rev) == 0x3120 && | |
+ le16_to_cpu(rp->hci_ver) == BLUETOOTH_VER_4_0) { | |
+ bt_dev_warn(hdev, "CSR: detected a fake CSR dongle with broken EDR filters\n"); | |
+ | |
+ set_bit(HCI_QUIRK_BROKEN_EDR_FILTERS, &hdev->quirks); | |
+ } | |
} | |
kfree_skb(skb); | |
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h | |
index c8e67042a..af37b179d 100644 | |
--- a/include/net/bluetooth/hci.h | |
+++ b/include/net/bluetooth/hci.h | |
@@ -238,6 +238,11 @@ enum { | |
* during the hdev->setup vendor callback. | |
*/ | |
HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, | |
+ | |
+ /* When this quirk is set, then EDR filters setting will be | |
+ * excluded during initialization procedure. | |
+ */ | |
+ HCI_QUIRK_BROKEN_EDR_FILTERS | |
}; | |
/* HCI device flags */ | |
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c | |
index c4aa2cbb9..e19e48162 100644 | |
--- a/net/bluetooth/hci_core.c | |
+++ b/net/bluetooth/hci_core.c | |
@@ -272,6 +272,7 @@ static void bredr_setup(struct hci_request *req) | |
{ | |
__le16 param; | |
__u8 flt_type; | |
+ struct hci_dev *hdev = req->hdev; | |
/* Read Buffer Size (ACL mtu, max pkt, etc.) */ | |
hci_req_add(req, HCI_OP_READ_BUFFER_SIZE, 0, NULL); | |
@@ -291,9 +292,11 @@ static void bredr_setup(struct hci_request *req) | |
/* Read Current IAC LAP */ | |
hci_req_add(req, HCI_OP_READ_CURRENT_IAC_LAP, 0, NULL); | |
- /* Clear Event Filters */ | |
- flt_type = HCI_FLT_CLEAR_ALL; | |
- hci_req_add(req, HCI_OP_SET_EVENT_FLT, 1, &flt_type); | |
+ if (!test_bit(HCI_QUIRK_BROKEN_EDR_FILTERS, &hdev->quirks)) { | |
+ /* Clear Event Filters */ | |
+ flt_type = HCI_FLT_CLEAR_ALL; | |
+ hci_req_add(req, HCI_OP_SET_EVENT_FLT, 1, &flt_type); | |
+ } | |
/* Connection accept timeout ~20 secs */ | |
param = cpu_to_le16(0x7d00); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment