bluetooth: host: smp: Add runtime check for central-specific path

Added run-time BT_CENTRAL role check for the path that was
central specific and did not have such check.

When multi-role BT device tried to pair without bonding (peripheral role)
while already previously bonded with the same device on another
Bluetooth identity, pairing failed.
It executed central-specific code, which should not be executed in case
when the device acts as peripheral (as it is even opt-out from code when
CONFIG_BT_CENTRAL is not enabled).

Signed-off-by: Mateusz Kapala <mateusz.kapala@nordicsemi.no>
This commit is contained in:
Mateusz Kapala 2023-10-04 11:58:46 +02:00 committed by Fabio Baltieri
commit 7a1b194a97

View file

@ -4706,6 +4706,7 @@ static void bt_smp_encrypt_change(struct bt_l2cap_chan *chan,
*/
if (IS_ENABLED(CONFIG_BT_CENTRAL) &&
IS_ENABLED(CONFIG_BT_PRIVACY) &&
conn->role == BT_HCI_ROLE_CENTRAL &&
!(smp->remote_dist & BT_SMP_DIST_ID_KEY)) {
uint8_t smp_err;