Skip to content

Commit 7e4bcff

Browse files
joerchanjhedberg
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 ee4006e commit 7e4bcff

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
@@ -1793,10 +1793,13 @@ static void smp_pairing_complete(struct bt_smp *smp, u8_t status)
17931793
} else {
17941794
u8_t auth_err = auth_err_get(status);
17951795

1796-
/*
1797-
* Clear the key pool entry in case of pairing failure.
1796+
/* Clear the key pool entry in case of pairing failure if the
1797+
* keys already existed before the pairing procedure or the
1798+
* pairing failed during key distribution.
17981799
*/
1799-
if (smp->chan.chan.conn->le.keys) {
1800+
if (smp->chan.chan.conn->le.keys &&
1801+
(!smp->chan.chan.conn->le.keys->enc_size ||
1802+
atomic_test_bit(smp->flags, SMP_FLAG_KEYS_DISTR))) {
18001803
bt_keys_clear(smp->chan.chan.conn->le.keys);
18011804
smp->chan.chan.conn->le.keys = NULL;
18021805
}

0 commit comments

Comments
 (0)