diff mbox series

[v2] Bluetooth: hci_h4: Fix padding calculation error within h4_recv_buf()

Message ID 1637052698-14326-1-git-send-email-zijuhu@codeaurora.org
State Superseded
Headers show
Series [v2] Bluetooth: hci_h4: Fix padding calculation error within h4_recv_buf() | expand

Commit Message

Zijun Hu Nov. 16, 2021, 8:51 a.m. UTC
From: Zijun Hu <quic_zijuhu@quicinc.com>

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>
---
 drivers/bluetooth/hci_h4.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Marcel Holtmann Nov. 16, 2021, 1:54 p.m. UTC | #1
Hi Zijun,

> 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>
> ---
> drivers/bluetooth/hci_h4.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel
diff mbox series

Patch

diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c
index 4b3b14a34794..1d0cdf023243 100644
--- a/drivers/bluetooth/hci_h4.c
+++ b/drivers/bluetooth/hci_h4.c
@@ -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 */