Commit 314d8cd2 authored by Luiz Augusto von Dentz's avatar Luiz Augusto von Dentz Committed by Marcel Holtmann
Browse files

Bluetooth: hci_event: Fix HCI_EV_VENDOR max_len



HCI_EV_VENDOR is in fact variable length since it acts as metaevent
where a vendor can implement their own event sets.

In addition to it this makes use of bt_dev_warn_ratelimited to supress
the amount of logging in case the event has more data than expected.

Fixes: 3e54c589 ("Bluetooth: hci_event: Use of a function table to handle HCI event")
Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 2d4b37b6
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -6844,7 +6844,7 @@ static const struct hci_ev {
	HCI_EV(HCI_EV_NUM_COMP_BLOCKS, hci_num_comp_blocks_evt,
	       sizeof(struct hci_ev_num_comp_blocks)),
	/* [0xff = HCI_EV_VENDOR] */
	HCI_EV(HCI_EV_VENDOR, msft_vendor_evt, 0),
	HCI_EV_VL(HCI_EV_VENDOR, msft_vendor_evt, 0, HCI_MAX_EVENT_SIZE),
};

static void hci_event_func(struct hci_dev *hdev, u8 event, struct sk_buff *skb,
@@ -6869,7 +6869,8 @@ static void hci_event_func(struct hci_dev *hdev, u8 event, struct sk_buff *skb,
	 * decide if that is acceptable.
	 */
	if (skb->len > ev->max_len)
		bt_dev_warn(hdev, "unexpected event 0x%2.2x length: %u > %u",
		bt_dev_warn_ratelimited(hdev,
					"unexpected event 0x%2.2x length: %u > %u",
					event, skb->len, ev->max_len);

	data = hci_ev_skb_pull(hdev, skb, event, ev->min_len);