Skip to content

Commit 2426978

Browse files
joerchannashif
authored andcommitted
Bluetooth: SMP: Fix bond lost on pairing failure.
Fix an an issue where established bonding information in the peripheral are deleted when the central does not have the bond information. This could be because the central has removed the bond information, or this is in fact not the central but someone spoofing it's identity, or an accidental RPA match. This is a regression from: a3e89e8 Signed-off-by: Joakim Andersson <[email protected]>
1 parent 8d75e8e commit 2426978

File tree

1 file changed

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

1 file changed

+6
-3
lines changed

subsys/bluetooth/host/smp.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,10 +1580,13 @@ static void smp_pairing_complete(struct bt_smp *smp, u8_t status)
15801580
bond_flag);
15811581
}
15821582
} else {
1583-
/*
1584-
* Clear the key pool entry in case of pairing failure.
1583+
/* Clear the key pool entry in case of pairing failure if the
1584+
* keys already existed before the pairing procedure or the
1585+
* pairing failed during key distribution.
15851586
*/
1586-
if (smp->chan.chan.conn->le.keys) {
1587+
if (smp->chan.chan.conn->le.keys &&
1588+
(!smp->chan.chan.conn->le.keys->enc_size ||
1589+
atomic_test_bit(smp->flags, SMP_FLAG_KEYS_DISTR))) {
15871590
bt_keys_clear(smp->chan.chan.conn->le.keys);
15881591
smp->chan.chan.conn->le.keys = NULL;
15891592
}

0 commit comments

Comments
 (0)