mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable.git
synced 2025-09-15 11:28:36 +10:00
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: f428091858
("Bluetooth: Simplify num_comp_pkts_evt function")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
b7fafbc499
commit
15bf2c6391
@ -4404,7 +4404,17 @@ static void hci_num_comp_pkts_evt(struct hci_dev *hdev, void *data,
|
|||||||
if (!conn)
|
if (!conn)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
conn->sent -= count;
|
/* Check if there is really enough packets outstanding before
|
||||||
|
* attempting to decrease the sent counter otherwise it could
|
||||||
|
* underflow..
|
||||||
|
*/
|
||||||
|
if (conn->sent >= count) {
|
||||||
|
conn->sent -= count;
|
||||||
|
} else {
|
||||||
|
bt_dev_warn(hdev, "hcon %p sent %u < count %u",
|
||||||
|
conn, conn->sent, count);
|
||||||
|
conn->sent = 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i)
|
||||||
hci_conn_tx_dequeue(conn);
|
hci_conn_tx_dequeue(conn);
|
||||||
|
Loading…
Reference in New Issue
Block a user