Bluetooth: hci_uart: Fix zero len data packet reception issue [Linux 4.3]

This Linux kernel change "Bluetooth: hci_uart: Fix zero len data packet reception issue" is included in the Linux 4.3 release. This change is authored by Loic Poulain <loic.poulain [at] intel.com> on Mon Aug 24 18:57:57 2015 +0200. The commit for this change in Linux stable tree is e549916 (patch).

Bluetooth: hci_uart: Fix zero len data packet reception issue

Packets with a variable length value equal to zero were not received.

Since no more data expected (and input buffer entirely consumed), we
need to complete/forward the packet immediately instead of waiting for
more data.

Signed-off-by: Loic Poulain <loic.poulain@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

There are 9 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/bluetooth/hci_h4.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c
index 57faddc..eec3f28 100644
--- a/drivers/bluetooth/hci_h4.c
+++ b/drivers/bluetooth/hci_h4.c
@@ -223,8 +223,7 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
            switch ((&pkts[i])->lsize) {
            case 0:
                /* No variable data length */
-               (&pkts[i])->recv(hdev, skb);
-               skb = NULL;
+               dlen = 0;
                break;
            case 1:
                /* Single octet variable length */
@@ -252,6 +251,12 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
                kfree_skb(skb);
                return ERR_PTR(-EILSEQ);
            }
+
+           if (!dlen) {
+               /* No more data, complete frame */
+               (&pkts[i])->recv(hdev, skb);
+               skb = NULL;
+           }
        } else {
            /* Complete frame */
            (&pkts[i])->recv(hdev, skb);

Leave a Reply

Your email address will not be published. Required fields are marked *