Bluetooth: host: Don't call callbacks on unexpected SMP PDUs

When receiving unexpected SMP PDUs with no pairing procedures in
progress don't treat it as a pairing procedure that has failed.
This causes unexpected SMP PDUs to trigger the pairing failed and
security changed callback at unexpected times.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
Joakim Andersson 2021-02-08 15:18:57 +01:00 committed by Anas Nashif
commit 0cc5dc1839

View file

@ -1915,8 +1915,12 @@ static int smp_error(struct bt_smp *smp, uint8_t reason)
struct bt_smp_pairing_fail *rsp;
struct net_buf *buf;
/* reset context and report */
smp_pairing_complete(smp, reason);
if (atomic_test_bit(smp->flags, SMP_FLAG_PAIRING) ||
atomic_test_bit(smp->flags, SMP_FLAG_ENC_PENDING) ||
atomic_test_bit(smp->flags, SMP_FLAG_SEC_REQ)) {
/* reset context and report */
smp_pairing_complete(smp, reason);
}
buf = smp_create_pdu(smp, BT_SMP_CMD_PAIRING_FAIL, sizeof(*rsp));
if (!buf) {