[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240214012328.BlueZ.1.I10eda6f375bc8dfedf4eef3a8cf6572c65803afc@changeid>
Date: Wed, 14 Feb 2024 01:23:29 +0800
From: Hsin-chen Chuang <chharry@...omium.org>
To: linux-bluetooth@...r.kernel.org
Cc: chromeos-bluetooth-upstreaming@...omium.org,
Hsin-chen Chuang <chharry@...omium.org>,
Johan Hedberg <johan.hedberg@...il.com>,
Luiz Augusto von Dentz <luiz.dentz@...il.com>,
Marcel Holtmann <marcel@...tmann.org>,
linux-kernel@...r.kernel.org
Subject: [BlueZ PATCH] Bluetooth: hci_core: Skip hci_cmd_work if hci_request is pending
hci_cmd_work overwrites the hdev->sent_cmd which contains the required
info for a hci_request to work. In the real world, it's observed that
a request from hci_le_ext_create_conn_sync could be interrupted by
the authentication (hci_conn_auth) caused by rfcomm_sock_connect. When
it happends, hci_le_ext_create_conn_sync hangs until timeout; If the
LE connection is triggered by MGMT, it freezes the whole MGMT interface.
Signed-off-by: Hsin-chen Chuang <chharry@...omium.org>
---
net/bluetooth/hci_core.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 34c8dca2069f..e3706889976d 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -4213,8 +4213,11 @@ static void hci_cmd_work(struct work_struct *work)
BT_DBG("%s cmd_cnt %d cmd queued %d", hdev->name,
atomic_read(&hdev->cmd_cnt), skb_queue_len(&hdev->cmd_q));
- /* Send queued commands */
- if (atomic_read(&hdev->cmd_cnt)) {
+ /* Send queued commands. Don't send the command when there is a pending
+ * hci_request because the request callbacks would be overwritten.
+ */
+ if (atomic_read(&hdev->cmd_cnt) &&
+ !hci_dev_test_flag(hdev, HCI_CMD_PENDING)) {
skb = skb_dequeue(&hdev->cmd_q);
if (!skb)
return;
--
2.43.0.687.g38aa6559b0-goog
Powered by blists - more mailing lists