Commit a789c70c authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files
Luiz Augusto von Dentz says:

====================
bluetooth pull request for net:

 - Fix regressions with CSR controller clones
 - Fix support for Read Local Supported Codecs V2
 - Fix overflow on L2CAP code
 - Fix missing hci_dev_put on ISO and L2CAP code

* tag 'for-net-2022-12-02' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth:
  Bluetooth: Fix crash when replugging CSR fake controllers
  Bluetooth: Fix not cleanup led when bt_init fails
  Bluetooth: Fix support for Read Local Supported Codecs V2
  Bluetooth: Remove codec id field in vendor codec definition
  Bluetooth: L2CAP: Fix u8 overflow
  Bluetooth: silence a dmesg error message in hci_request.c
  Bluetooth: hci_conn: add missing hci_dev_put() in iso_listen_bis()
  Bluetooth: 6LoWPAN: add missing hci_dev_put() in get_l2cap_conn()
  Bluetooth: btusb: Add debug message for CSR controllers
  Bluetooth: btusb: Fix CSR clones again by re-adding ERR_DATA_REPORTING quirk
====================

Link: https://lore.kernel.org/r/20221202213726.2801581-1-luiz.dentz@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents e931a173 b5ca3387
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2056,6 +2056,11 @@ static int btusb_setup_csr(struct hci_dev *hdev)

	rp = (struct hci_rp_read_local_version *)skb->data;

	bt_dev_info(hdev, "CSR: Setting up dongle with HCI ver=%u rev=%04x; LMP ver=%u subver=%04x; manufacturer=%u",
		le16_to_cpu(rp->hci_ver), le16_to_cpu(rp->hci_rev),
		le16_to_cpu(rp->lmp_ver), le16_to_cpu(rp->lmp_subver),
		le16_to_cpu(rp->manufacturer));

	/* Detect a wide host of Chinese controllers that aren't CSR.
	 *
	 * Known fake bcdDevices: 0x0100, 0x0134, 0x1915, 0x2520, 0x7558, 0x8891
@@ -2118,6 +2123,7 @@ static int btusb_setup_csr(struct hci_dev *hdev)
		 * without these the controller will lock up.
		 */
		set_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks);
		set_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks);
		set_bit(HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL, &hdev->quirks);
		set_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks);

+11 −1
Original line number Diff line number Diff line
@@ -228,6 +228,17 @@ enum {
	 */
	HCI_QUIRK_VALID_LE_STATES,

	/* When this quirk is set, then erroneous data reporting
	 * is ignored. This is mainly due to the fact that the HCI
	 * Read Default Erroneous Data Reporting command is advertised,
	 * but not supported; these controllers often reply with unknown
	 * command and tend to lock up randomly. Needing a hard reset.
	 *
	 * This quirk can be set before hci_register_dev is called or
	 * during the hdev->setup vendor callback.
	 */
	HCI_QUIRK_BROKEN_ERR_DATA_REPORTING,

	/*
	 * When this quirk is set, then the hci_suspend_notifier is not
	 * registered. This is intended for devices which drop completely
@@ -1424,7 +1435,6 @@ struct hci_std_codecs_v2 {
} __packed;

struct hci_vnd_codec_v2 {
	__u8	id;
	__le16	cid;
	__le16	vid;
	__u8	transport;
+1 −0
Original line number Diff line number Diff line
@@ -972,6 +972,7 @@ static int get_l2cap_conn(char *buf, bdaddr_t *addr, u8 *addr_type,
	hci_dev_lock(hdev);
	hcon = hci_conn_hash_lookup_le(hdev, addr, *addr_type);
	hci_dev_unlock(hdev);
	hci_dev_put(hdev);

	if (!hcon)
		return -ENOENT;
+3 −1
Original line number Diff line number Diff line
@@ -737,7 +737,7 @@ static int __init bt_init(void)

	err = bt_sysfs_init();
	if (err < 0)
		return err;
		goto cleanup_led;

	err = sock_register(&bt_sock_family_ops);
	if (err)
@@ -773,6 +773,8 @@ static int __init bt_init(void)
	sock_unregister(PF_BLUETOOTH);
cleanup_sysfs:
	bt_sysfs_cleanup();
cleanup_led:
	bt_leds_cleanup();
	return err;
}

+10 −9
Original line number Diff line number Diff line
@@ -72,9 +72,8 @@ static void hci_read_codec_capabilities(struct hci_dev *hdev, __u8 transport,
				continue;
			}

			skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_CODEC_CAPS,
					     sizeof(*cmd), cmd,
					     HCI_CMD_TIMEOUT);
			skb = __hci_cmd_sync_sk(hdev, HCI_OP_READ_LOCAL_CODEC_CAPS,
						sizeof(*cmd), cmd, 0, HCI_CMD_TIMEOUT, NULL);
			if (IS_ERR(skb)) {
				bt_dev_err(hdev, "Failed to read codec capabilities (%ld)",
					   PTR_ERR(skb));
@@ -127,8 +126,8 @@ void hci_read_supported_codecs(struct hci_dev *hdev)
	struct hci_op_read_local_codec_caps caps;
	__u8 i;

	skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_CODECS, 0, NULL,
			     HCI_CMD_TIMEOUT);
	skb = __hci_cmd_sync_sk(hdev, HCI_OP_READ_LOCAL_CODECS, 0, NULL,
				0, HCI_CMD_TIMEOUT, NULL);

	if (IS_ERR(skb)) {
		bt_dev_err(hdev, "Failed to read local supported codecs (%ld)",
@@ -158,7 +157,8 @@ void hci_read_supported_codecs(struct hci_dev *hdev)
	for (i = 0; i < std_codecs->num; i++) {
		caps.id = std_codecs->codec[i];
		caps.direction = 0x00;
		hci_read_codec_capabilities(hdev, LOCAL_CODEC_ACL_MASK, &caps);
		hci_read_codec_capabilities(hdev,
					    LOCAL_CODEC_ACL_MASK | LOCAL_CODEC_SCO_MASK, &caps);
	}

	skb_pull(skb, flex_array_size(std_codecs, codec, std_codecs->num)
@@ -178,7 +178,8 @@ void hci_read_supported_codecs(struct hci_dev *hdev)
		caps.cid = vnd_codecs->codec[i].cid;
		caps.vid = vnd_codecs->codec[i].vid;
		caps.direction = 0x00;
		hci_read_codec_capabilities(hdev, LOCAL_CODEC_ACL_MASK, &caps);
		hci_read_codec_capabilities(hdev,
					    LOCAL_CODEC_ACL_MASK | LOCAL_CODEC_SCO_MASK, &caps);
	}

error:
@@ -194,8 +195,8 @@ void hci_read_supported_codecs_v2(struct hci_dev *hdev)
	struct hci_op_read_local_codec_caps caps;
	__u8 i;

	skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_CODECS_V2, 0, NULL,
			     HCI_CMD_TIMEOUT);
	skb = __hci_cmd_sync_sk(hdev, HCI_OP_READ_LOCAL_CODECS_V2, 0, NULL,
				0, HCI_CMD_TIMEOUT, NULL);

	if (IS_ERR(skb)) {
		bt_dev_err(hdev, "Failed to read local supported codecs (%ld)",
Loading