Skip to contentSkip to conversation

bearer: Fix LE Disconnect for devices with a random address

PATCH Applied Kevin Dewald 3 participants 3 messages Nov 13 – Nov 16 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bearer: Fix LE Disconnect for devices with a random address

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(-)
src/bearer.c +6 -2
index ebcdc2b4c..e5fc2ee3a 100644
@@ -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

Signature · 1 line
2.54.0 (Apple Git-157)
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1210153/

---Test result---

Test Summary:

CheckPatch                    PASS      0.47 seconds
GitLint                       PASS      0.33 seconds
BuildEll                      PASS      19.02 seconds
BluezMake                     PASS      289.71 seconds
CheckSmatch                   PASS      293.34 seconds
bluezmakeextell               PASS      98.48 seconds
TestFunctional                PASS      1136.16 seconds
IncrementalBuild              PASS      286.75 seconds
ScanBuild                     PASS      1103.98 seconds

https://github.com/bluez/bluez/pull/2819

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Kevin Dewald
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 8 lines · On Thu, 12 Nov 2026 20:27:44 -0800 you wrote:

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.

[...]

Here is the summary with links:
- [BlueZ] bearer: Fix LE Disconnect for devices with a random address

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=f9f3a6eca27a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html