Branch: refs/heads/996842 Home: https://github.com/bluez/bluez Commit: 9b0325f0a941942cb4f3fe95e69c7f5c9e156ecf https://github.com/bluez/bluez/commit/9b0325f0a941942cb4f3fe95e69c7f5c9e156ecf Author: xinpeng.wang <wangxinpeng@xxxxxxxxxxxxx> Date: 2025-08-29 (Fri, 29 Aug 2025) Changed paths: M src/adapter.c Log Message: ----------- device: Recreate paired device from storage after failed restore When a USB Bluetooth adapter is resumed from S4 suspend, the kernel may trigger an "index remove" followed by an "index add". BlueZ responds by removing all devices and attempting to recreate them from stored configuration (storage). However, if a connected A2DP device disconnects just before suspend, BlueZ may have started a disconnect timer (via set_disconnect_timer) but not yet freed the session. During this period: - The session pointer is set to NULL and becomes inaccessible. - The session still holds a reference to the device, preventing it from being freed. - As a result, the "index add" event fails to recreate the device from storage (due to D-Bus path conflict or incomplete cleanup). - Later, when the timer expires, a new device is created from discovery data, bypassing storage and causing it to appear as unpaired. This leads to loss of pairing information and confuses desktop applications that rely on paired/unpaired state. This patch enhances the device creation logic: if loading a paired device from storage previously failed (e.g., due to pending session cleanup), its address is recorded in the adapter's pending list. Later, when creating a device from scan data, BlueZ checks this list and re-attempts creation from storage if matched, ensuring the correct paired state is restored. This ensures that devices are properly restored after suspend/resume cycles, even in race conditions involving delayed session cleanup. Signed-off-by: xinpeng.wang <wangxinpeng@xxxxxxxxxxxxx> To unsubscribe from these emails, change your notification settings at https://github.com/bluez/bluez/settings/notifications