bthost: Fix not initializing address types properly
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 13 Aug 2021 20:54:10 +0000 (13:54 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:36 +0000 (19:08 +0530)
The address type given to the init_conn is the peer address type
(btdev) not the bthost address type, the old code assume it could use
since only BDADDR_BREDR or BDADDR_LE_PUBLIC was tested but with the
upcoming support for LL Privacy the peer address type would become
BDADDR_LE_RANDOM which cannot be used as address type of bthost as that
doesn't support random addresses and would likely cause SMP to fail when
pairing.

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

index e5f6a9c..32d8a08 100755 (executable)
@@ -950,14 +950,20 @@ static void init_conn(struct bthost *bthost, uint16_t handle,
 
        if (bthost->conn_init) {
                ia = bthost->bdaddr;
-               ia_type = addr_type;
-               ra = conn->bdaddr;
-               ra_type = conn->addr_type;
+               if (addr_type == BDADDR_BREDR)
+                       ia_type = addr_type;
+               else
+                       ia_type = BDADDR_LE_PUBLIC;
+               ra = bdaddr;
+               ra_type = addr_type;
        } else {
-               ia = conn->bdaddr;
-               ia_type = conn->addr_type;
+               ia = bdaddr;
+               ia_type = addr_type;
                ra = bthost->bdaddr;
-               ra_type = addr_type;
+               if (addr_type == BDADDR_BREDR)
+                       ra_type = addr_type;
+               else
+                       ra_type = BDADDR_LE_PUBLIC;
        }
 
        conn->smp_data = smp_conn_add(bthost->smp_data, handle, ia, ia_type,