Skip to content

Commit 15bf2c6

Browse files
committed
Bluetooth: hci_event: Detect if HCI_EV_NUM_COMP_PKTS is unbalanced
This attempts to detect if HCI_EV_NUM_COMP_PKTS contain an unbalanced (more than currently considered outstanding) number of packets otherwise it could cause the hcon->sent to underflow and loop around breaking the tracking of the outstanding packets pending acknowledgment. Fixes: f428091 ("Bluetooth: Simplify num_comp_pkts_evt function") Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent b7fafbc commit 15bf2c6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

net/bluetooth/hci_event.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4404,7 +4404,17 @@ static void hci_num_comp_pkts_evt(struct hci_dev *hdev, void *data,
44044404
if (!conn)
44054405
continue;
44064406

4407-
conn->sent -= count;
4407+
/* Check if there is really enough packets outstanding before
4408+
* attempting to decrease the sent counter otherwise it could
4409+
* underflow..
4410+
*/
4411+
if (conn->sent >= count) {
4412+
conn->sent -= count;
4413+
} else {
4414+
bt_dev_warn(hdev, "hcon %p sent %u < count %u",
4415+
conn, conn->sent, count);
4416+
conn->sent = 0;
4417+
}
44084418

44094419
for (i = 0; i < count; ++i)
44104420
hci_conn_tx_dequeue(conn);

0 commit comments

Comments
 (0)