public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: hci_sync: fix hci_conn_del usage in hci_le_create_conn_sync
@ 2026-04-11 12:51 Pauli Virtanen
  2026-04-11 13:58 ` bluez.test.bot
  0 siblings, 1 reply; 2+ messages in thread
From: Pauli Virtanen @ 2026-04-11 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

Callers to hci_conn_del() shall hold hdev->lock and have informed socket
layer of teardown if needed. This was not done in
hci_le_create_conn_sync(); it also appears possible to reach here via
l2cap_chan_connect() with associated socket.

Fix by taking lock, checking conn validity, and adding hci_connect_cfm.

Fixes: 8e8b92ee60de5 ("Bluetooth: hci_sync: Add hci_le_create_conn_sync")
Signed-off-by: Pauli Virtanen <pav@iki.fi>
---
 net/bluetooth/hci_sync.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index fd3aacdea512..f950f87fa690 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -6602,7 +6602,12 @@ static int hci_le_create_conn_sync(struct hci_dev *hdev, void *data)
 		if (hci_dev_test_flag(hdev, HCI_LE_SCAN) &&
 		    hdev->le_scan_type == LE_SCAN_ACTIVE &&
 		    !hci_dev_test_flag(hdev, HCI_LE_SIMULTANEOUS_ROLES)) {
-			hci_conn_del(conn);
+			hci_dev_lock(hdev);
+			if (hci_conn_valid(hdev, conn)) {
+				hci_connect_cfm(conn, bt_status(-EBUSY));
+				hci_conn_del(conn);
+			}
+			hci_dev_unlock(hdev);
 			return -EBUSY;
 		}
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-11 13:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-11 12:51 [PATCH] Bluetooth: hci_sync: fix hci_conn_del usage in hci_le_create_conn_sync Pauli Virtanen
2026-04-11 13:58 ` bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox