]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Bluetooth: hci_core: Fix LE quote calculation
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 12 Aug 2024 15:22:08 +0000 (11:22 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Sep 2024 11:17:39 +0000 (13:17 +0200)
[ Upstream commit 932021a11805b9da4bd6abf66fe233cccd59fe0e ]

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: https://github.com/bluez/bluez/issues/915
Fixes: 73d80deb7bdf ("Bluetooth: prioritizing data over HCI")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/bluetooth/hci_core.c

index c8c1cd55c0eb097136563add3fcd9a5949781384..9787a4c551138da4b7994ad08e8a977721e4f7b4 100644 (file)
@@ -4685,19 +4685,19 @@ static void hci_sched_le(struct hci_dev *hdev)
 {
        struct hci_chan *chan;
        struct sk_buff *skb;
-       int quote, cnt, tmp;
+       int quote, *cnt, tmp;
 
        BT_DBG("%s", hdev->name);
 
        if (!hci_conn_num(hdev, LE_LINK))
                return;
 
-       cnt = hdev->le_pkts ? hdev->le_cnt : hdev->acl_cnt;
+       cnt = hdev->le_pkts ? &hdev->le_cnt : &hdev->acl_cnt;
 
-       __check_timeout(hdev, cnt, LE_LINK);
+       __check_timeout(hdev, *cnt, LE_LINK);
 
-       tmp = cnt;
-       while (cnt && (chan = hci_chan_sent(hdev, LE_LINK, &quote))) {
+       tmp = *cnt;
+       while (*cnt && (chan = hci_chan_sent(hdev, LE_LINK, &quote))) {
                u32 priority = (skb_peek(&chan->data_q))->priority;
                while (quote-- && (skb = skb_peek(&chan->data_q))) {
                        BT_DBG("chan %p skb %p len %d priority %u", chan, skb,
@@ -4712,7 +4712,7 @@ static void hci_sched_le(struct hci_dev *hdev)
                        hci_send_frame(hdev, skb);
                        hdev->le_last_tx = jiffies;
 
-                       cnt--;
+                       (*cnt)--;
                        chan->sent++;
                        chan->conn->sent++;
 
@@ -4722,12 +4722,7 @@ static void hci_sched_le(struct hci_dev *hdev)
                }
        }
 
-       if (hdev->le_pkts)
-               hdev->le_cnt = cnt;
-       else
-               hdev->acl_cnt = cnt;
-
-       if (cnt != tmp)
+       if (*cnt != tmp)
                hci_prio_recalculate(hdev, LE_LINK);
 }