device: Fix not updating the auto-connect/accept list
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tue, 2 Nov 2021 00:08:15 +0000 (17:08 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:37 +0000 (19:08 +0530)
When receiving a new IRK the device address is updated but the old
address is not removed from the auto-connect/accept list.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/device.c

index e99824a..bb26724 100644 (file)
@@ -6968,6 +6968,8 @@ void device_set_class(struct btd_device *device, uint32_t class)
 void device_update_addr(struct btd_device *device, const bdaddr_t *bdaddr,
                                                        uint8_t bdaddr_type)
 {
+       bool auto_connect = device->auto_connect;
+
        if (!bacmp(bdaddr, &device->bdaddr) &&
                                        bdaddr_type == device->bdaddr_type)
                return;
@@ -6977,6 +6979,12 @@ void device_update_addr(struct btd_device *device, const bdaddr_t *bdaddr,
         */
        device->le = true;
 
+       /* Remove old address from accept/auto-connect list since its address
+        * will be changed.
+        */
+       if (auto_connect)
+               device_set_auto_connect(device, FALSE);
+
        bacpy(&device->bdaddr, bdaddr);
        device->bdaddr_type = bdaddr_type;
 
@@ -6986,6 +6994,9 @@ void device_update_addr(struct btd_device *device, const bdaddr_t *bdaddr,
                                                DEVICE_INTERFACE, "Address");
        g_dbus_emit_property_changed(dbus_conn, device->path,
                                        DEVICE_INTERFACE, "AddressType");
+
+       if (auto_connect)
+               device_set_auto_connect(device, TRUE);
 }
 
 void device_set_bredr_support(struct btd_device *device)