Skip to content

Commit

Permalink
Bluetooth: guard against controllers sending zero'd events
Browse files Browse the repository at this point in the history
Some controllers have been observed to send zero'd events under some
conditions.  This change guards against this condition as well as adding
a trace to facilitate diagnosability of this condition.

Signed-off-by: Alain Michaud <alainm@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
  • Loading branch information
Alain Michaud authored and Marcel Holtmann committed Mar 4, 2020
1 parent 8a208b2 commit 08bb4da
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions net/bluetooth/hci_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -5868,6 +5868,11 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
u8 status = 0, event = hdr->evt, req_evt = 0;
u16 opcode = HCI_OP_NOP;

if (!event) {
bt_dev_warn(hdev, "Received unexpected HCI Event 00000000");
goto done;
}

if (hdev->sent_cmd && bt_cb(hdev->sent_cmd)->hci.req_event == event) {
struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data;
opcode = __le16_to_cpu(cmd_hdr->opcode);
Expand Down Expand Up @@ -6079,6 +6084,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
req_complete_skb(hdev, status, opcode, orig_skb);
}

done:
kfree_skb(orig_skb);
kfree_skb(skb);
hdev->stat.evt_rx++;
Expand Down

0 comments on commit 08bb4da

Please sign in to comment.