]> git.baikalelectronics.ru Git - kernel.git/commitdiff
Bluetooth: hci_h4: Fix padding calculation error within h4_recv_buf()
authorZijun Hu <quic_zijuhu@quicinc.com>
Tue, 16 Nov 2021 08:51:38 +0000 (16:51 +0800)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 16 Nov 2021 12:57:25 +0000 (13:57 +0100)
it is erroneous to calculate padding by subtracting length of type
indication from skb->len, it will cause data analysis error for
alignment which is greater than 1, so fixed by adding length of type
indication with skb->len.

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/bluetooth/hci_h4.c

index 4b3b14a3479472c8c66ef6e21c56dacb1d605e0c..1d0cdf02324373062f82e69d7acb1cd28c4271f9 100644 (file)
@@ -252,7 +252,7 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
                        }
 
                        if (!dlen) {
-                               hu->padding = (skb->len - 1) % alignment;
+                               hu->padding = (skb->len + 1) % alignment;
                                hu->padding = (alignment - hu->padding) % alignment;
 
                                /* No more data, complete frame */
@@ -260,7 +260,7 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
                                skb = NULL;
                        }
                } else {
-                       hu->padding = (skb->len - 1) % alignment;
+                       hu->padding = (skb->len + 1) % alignment;
                        hu->padding = (alignment - hu->padding) % alignment;
 
                        /* Complete frame */