NFC: Dot not dispatch HCI event received on unopened pipe
authorEric Lapuyade <eric.lapuyade@linux.intel.com>
Wed, 17 Oct 2012 14:49:12 +0000 (16:49 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 19 Nov 2012 22:56:58 +0000 (23:56 +0100)
A chip with pre-opened gates may send events on a gate that nobody
has opened in the handset host. Discard those events.

Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
net/nfc/hci/core.c

index a58db89b455594f627a4585d18aa2d4248127d2e..38d5f96dfd10f72a9c9ce10660d409f052b5b1b6 100644 (file)
@@ -286,6 +286,12 @@ void nfc_hci_event_received(struct nfc_hci_dev *hdev, u8 pipe, u8 event,
                            struct sk_buff *skb)
 {
        int r = 0;
+       u8 gate = nfc_hci_pipe2gate(hdev, pipe);
+
+       if (gate == 0xff) {
+               pr_err("Discarded event %x to unopened pipe %x\n", event, pipe);
+               goto exit;
+       }
 
        switch (event) {
        case NFC_HCI_EVT_TARGET_DISCOVERED:
@@ -309,14 +315,11 @@ void nfc_hci_event_received(struct nfc_hci_dev *hdev, u8 pipe, u8 event,
                        goto exit;
                }
 
-               r = nfc_hci_target_discovered(hdev,
-                                             nfc_hci_pipe2gate(hdev, pipe));
+               r = nfc_hci_target_discovered(hdev, gate);
                break;
        default:
                if (hdev->ops->event_received) {
-                       hdev->ops->event_received(hdev,
-                                               nfc_hci_pipe2gate(hdev, pipe),
-                                               event, skb);
+                       hdev->ops->event_received(hdev, gate, event, skb);
                        return;
                }