Bluetooth: hci_h4: Fix padding calculation error within h4_recv_buf()

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>
This commit is contained in:
Zijun Hu 2021-11-16 16:51:38 +08:00 committed by Marcel Holtmann
parent 258f56d11b
commit dd2ac1d6d4
1 changed files with 2 additions and 2 deletions

View File

@ -252,7 +252,7 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
} }
if (!dlen) { if (!dlen) {
hu->padding = (skb->len - 1) % alignment; hu->padding = (skb->len + 1) % alignment;
hu->padding = (alignment - hu->padding) % alignment; hu->padding = (alignment - hu->padding) % alignment;
/* No more data, complete frame */ /* 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; skb = NULL;
} }
} else { } else {
hu->padding = (skb->len - 1) % alignment; hu->padding = (skb->len + 1) % alignment;
hu->padding = (alignment - hu->padding) % alignment; hu->padding = (alignment - hu->padding) % alignment;
/* Complete frame */ /* Complete frame */