From: Kevin Dewald <kevin@simpleble.org>
To: linux-bluetooth@vger.kernel.org
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
Marcel Holtmann <marcel@holtmann.org>,
linux-kernel@vger.kernel.org, Kevin Dewald <kevin@simpleble.org>
Subject: [PATCH v2] Bluetooth: hci_event: Clear explicit connect state on LE connection
Date: Fri, 23 Oct 2026 12:14:37 -0700 [thread overview]
Message-ID: <20261023191437.87024-1-kevin@simpleble.org> (raw)
Since commit 6cd29ec6ae5e ("Bluetooth: hci_sync: Wait for proper events
when connecting LE"), create_le_conn_complete() only runs once the LE
Connection Complete event has been handled, and le_conn_complete_evt()
has already removed the connection parameters from pend_le_conns by
then. hci_connect_le_scan_cleanup() looks the parameters up in
pend_le_conns, so after a successful connection it no longer clears
explicit_connect, nor deletes the parameters that were only created for
the explicit connect.
The parameters of every device connected through an explicit connect,
such as an L2CAP or ATT connect or MGMT Pair Device, are thus left with
explicit_connect set. MGMT Remove Device for all devices then keeps
them as HCI_AUTO_CONN_EXPLICIT instead of freeing them, and if the
device was set to auto-connect and is disconnected, they also stay on
pend_le_conns: the kernel keeps scanning for the device and connects to
it as soon as it advertises, although no one asked for it any more.
Do the cleanup in le_conn_complete_evt() instead, where the explicit
connect request is fulfilled: clear explicit_connect, delete the
parameters if they only existed for it, and put report parameters back
on pend_le_reports. Auto-connect parameters are added back to
pend_le_conns on disconnection, as before. Update the comment in
hci_explicit_conn_params_set() that names hci_connect_le_scan_cleanup()
as the only place deleting them.
Fixes: 6cd29ec6ae5e ("Bluetooth: hci_sync: Wait for proper events when connecting LE")
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Kevin Dewald <kevin@simpleble.org>
---
v2:
- Update the comment in hci_explicit_conn_params_set() (Sashiko)
- Rebase on bluetooth-next 27731ba091
- No change for the subrate case Sashiko also raised, see the reply
to v1
v1: https://lore.kernel.org/linux-bluetooth/20261014224145.10801-1-kevin@simpleble.org/
net/bluetooth/hci_conn.c | 5 +++--
net/bluetooth/hci_event.c | 22 ++++++++++++++++++++++
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 29da3fe2b9..5de95408e6 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -1614,8 +1614,9 @@ static int hci_explicit_conn_params_set(struct hci_dev *hdev,
if (!params)
return -ENOMEM;
- /* If we created new params, mark them to be deleted in
- * hci_connect_le_scan_cleanup. It's different case than
+ /* If we created new params, mark them to be deleted once the
+ * explicit connect is done, see le_conn_complete_evt() and
+ * hci_connect_le_scan_cleanup(). It's different case than
* existing disabled params, those will stay after cleanup.
*/
params->auto_connect = HCI_AUTO_CONN_EXPLICIT;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 56ad10ab96..982b67aef4 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -6041,6 +6041,28 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
hci_conn_put(params->conn);
params->conn = NULL;
}
+
+ /* An explicit connect request is complete once connected, so
+ * clean it up here: hci_connect_le_scan_cleanup() no longer
+ * finds the params since they have just been removed from
+ * pend_le_conns.
+ */
+ if (params->explicit_connect) {
+ params->explicit_connect = false;
+
+ switch (params->auto_connect) {
+ case HCI_AUTO_CONN_EXPLICIT:
+ hci_conn_params_del(hdev, &conn->dst,
+ conn->dst_type);
+ break;
+ case HCI_AUTO_CONN_REPORT:
+ hci_pend_le_list_add(params,
+ &hdev->pend_le_reports);
+ break;
+ default:
+ break;
+ }
+ }
}
/* If we are central and have subrate parameters stored, queue a
base-commit: 27731ba091954eccddb2657053b590d2113e8d98
--
2.53.0
next reply other threads:[~2026-10-23 19:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 19:14 Kevin Dewald [this message]
2026-10-23 21:00 ` patchwork-bot+bluetooth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261023191437.87024-1-kevin@simpleble.org \
--to=kevin@simpleble.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®