Skip to content

Commit 932021a

Browse files
committed
Bluetooth: hci_core: Fix LE quote calculation
Function hci_sched_le needs to update the respective counter variable inplace other the likes of hci_quote_sent would attempt to use the possible outdated value of conn->{le_cnt,acl_cnt}. Link: bluez/bluez#915 Fixes: 73d80de ("Bluetooth: prioritizing data over HCI") Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent aae6b81 commit 932021a

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

net/bluetooth/hci_core.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3664,19 +3664,19 @@ static void hci_sched_le(struct hci_dev *hdev)
36643664
{
36653665
struct hci_chan *chan;
36663666
struct sk_buff *skb;
3667-
int quote, cnt, tmp;
3667+
int quote, *cnt, tmp;
36683668

36693669
BT_DBG("%s", hdev->name);
36703670

36713671
if (!hci_conn_num(hdev, LE_LINK))
36723672
return;
36733673

3674-
cnt = hdev->le_pkts ? hdev->le_cnt : hdev->acl_cnt;
3674+
cnt = hdev->le_pkts ? &hdev->le_cnt : &hdev->acl_cnt;
36753675

3676-
__check_timeout(hdev, cnt, LE_LINK);
3676+
__check_timeout(hdev, *cnt, LE_LINK);
36773677

3678-
tmp = cnt;
3679-
while (cnt && (chan = hci_chan_sent(hdev, LE_LINK, &quote))) {
3678+
tmp = *cnt;
3679+
while (*cnt && (chan = hci_chan_sent(hdev, LE_LINK, &quote))) {
36803680
u32 priority = (skb_peek(&chan->data_q))->priority;
36813681
while (quote-- && (skb = skb_peek(&chan->data_q))) {
36823682
BT_DBG("chan %p skb %p len %d priority %u", chan, skb,
@@ -3691,7 +3691,7 @@ static void hci_sched_le(struct hci_dev *hdev)
36913691
hci_send_frame(hdev, skb);
36923692
hdev->le_last_tx = jiffies;
36933693

3694-
cnt--;
3694+
(*cnt)--;
36953695
chan->sent++;
36963696
chan->conn->sent++;
36973697

@@ -3701,12 +3701,7 @@ static void hci_sched_le(struct hci_dev *hdev)
37013701
}
37023702
}
37033703

3704-
if (hdev->le_pkts)
3705-
hdev->le_cnt = cnt;
3706-
else
3707-
hdev->acl_cnt = cnt;
3708-
3709-
if (cnt != tmp)
3704+
if (*cnt != tmp)
37103705
hci_prio_recalculate(hdev, LE_LINK);
37113706
}
37123707

0 commit comments

Comments
 (0)