Skip to content

Commit ad96ae0

Browse files
joerchancarlescufi
authored andcommitted
Bluetooth: SMP: Set allowed commands before sending the SMP packet
Set the allowed command bitmask before sending the SMP packet. This avoids a race-condition in case the sending of the PDU made the current thread not ready and would not be scheduled back in time to set the bit before receiving the next SMP packet. Signed-off-by: Joakim Andersson <[email protected]>
1 parent d04e197 commit ad96ae0

File tree

1 file changed

+3
-3
lines changed
  • subsys/bluetooth/host

1 file changed

+3
-3
lines changed

subsys/bluetooth/host/smp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,12 +2377,12 @@ static uint8_t legacy_pairing_req(struct bt_smp *smp)
23772377
return 0;
23782378
}
23792379

2380+
atomic_set_bit(&smp->allowed_cmds, BT_SMP_CMD_PAIRING_CONFIRM);
23802381
ret = send_pairing_rsp(smp);
23812382
if (ret) {
23822383
return ret;
23832384
}
23842385

2385-
atomic_set_bit(&smp->allowed_cmds, BT_SMP_CMD_PAIRING_CONFIRM);
23862386

23872387
return legacy_request_tk(smp);
23882388
}
@@ -5066,23 +5066,23 @@ int bt_smp_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey)
50665066

50675067
if (IS_ENABLED(CONFIG_BT_CENTRAL) &&
50685068
smp->chan.chan.conn->role == BT_HCI_ROLE_MASTER) {
5069+
atomic_set_bit(&smp->allowed_cmds, BT_SMP_CMD_PAIRING_CONFIRM);
50695070
err = smp_send_pairing_confirm(smp);
50705071
if (err) {
50715072
smp_error(smp, BT_SMP_ERR_PASSKEY_ENTRY_FAILED);
50725073
return 0;
50735074
}
5074-
atomic_set_bit(&smp->allowed_cmds, BT_SMP_CMD_PAIRING_CONFIRM);
50755075
return 0;
50765076
}
50775077

50785078
if (IS_ENABLED(CONFIG_BT_PERIPHERAL) &&
50795079
atomic_test_bit(smp->flags, SMP_FLAG_CFM_DELAYED)) {
5080+
atomic_set_bit(&smp->allowed_cmds, BT_SMP_CMD_PAIRING_RANDOM);
50805081
err = smp_send_pairing_confirm(smp);
50815082
if (err) {
50825083
smp_error(smp, BT_SMP_ERR_PASSKEY_ENTRY_FAILED);
50835084
return 0;
50845085
}
5085-
atomic_set_bit(&smp->allowed_cmds, BT_SMP_CMD_PAIRING_RANDOM);
50865086
}
50875087

50885088
return 0;

0 commit comments

Comments
 (0)