From: Kevin Dewald <kevin@simpleble.org>
To: linux-bluetooth@vger.kernel.org
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
Kevin Dewald <kevin@simpleble.org>
Subject: [PATCH BlueZ] bearer: Fix LE Disconnect for devices with a random address
Date: Thu, 12 Nov 2026 20:27:44 -0800 [thread overview]
Message-ID: <20261113042744.55832-1-kevin@simpleble.org> (raw)
Disconnect passes bearer->type to btd_adapter_disconnect_device(), and
the LE bearer is always created with BDADDR_LE_PUBLIC. The kernel looks
up LE links by address type, so for a device with a random address it
finds no link and bluetoothd logs "Disconnecting failed: already
disconnected". The link stays up, and the Disconnect call is not
answered until the link drops some other way.
Use the address type of the device for LE, as Device1.Disconnect does.
Fixes: 4e21ebcaa5d0 ("bearer: Implement Connect/Disconnect methods")
Assisted-by: Claude:claude-opus-5.5
---
Tested on an RTL8761BU connected to an nRF52840 with a static random
address. Without the fix, Bearer.LE1.Disconnect got no reply within 10
seconds and left the link up, 3 times out of 3. With it, the call
replied after 2.3 to 2.8 seconds and the link went down. The functional
tests use public addresses, so they don't hit this.
src/bearer.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/bearer.c b/src/bearer.c
index ebcdc2b4c..e5fc2ee3a 100644
--- a/src/bearer.c
+++ b/src/bearer.c
@@ -109,13 +109,17 @@ static bool bearer_disconnect_link(gpointer user_data)
{
struct btd_bearer *bearer = user_data;
struct btd_device *device = bearer->device;
+ uint8_t type = bearer->type;
bearer->disconn_timer = 0;
- if (btd_device_bdaddr_type_connected(device, bearer->type))
+ if (type != BDADDR_BREDR)
+ type = device_get_le_address_type(device);
+
+ if (btd_device_bdaddr_type_connected(device, type))
btd_adapter_disconnect_device(device_get_adapter(device),
device_get_address(device),
- bearer->type);
+ type);
return FALSE;
}
base-commit: 20ffd285b58facfd1f2478d159a5f941b09d5be1
--
2.54.0 (Apple Git-157)
reply other threads:[~2026-11-13 4:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261113042744.55832-1-kevin@simpleble.org \
--to=kevin@simpleble.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
/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