Commit 24269781 authored by Joakim Andersson's avatar Joakim Andersson Committed by Anas Nashif
Browse files

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: a3e89e84

Signed-off-by: default avatarJoakim Andersson <joakim.andersson@nordicsemi.no>
parent 8d75e8e9
Loading
Loading
Loading
Loading
+6 −3
Changes for subsys/bluetooth/host/smp.c: 6 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -1580,10 +1580,13 @@ static void smp_pairing_complete(struct bt_smp *smp, u8_t status)
						  bond_flag);
		}
	} else {
		/*
		 * Clear the key pool entry in case of pairing failure.
		/* Clear the key pool entry in case of pairing failure if the
		 * keys already existed before the pairing procedure or the
		 * pairing failed during key distribution.
		 */
		if (smp->chan.chan.conn->le.keys) {
		if (smp->chan.chan.conn->le.keys &&
		    (!smp->chan.chan.conn->le.keys->enc_size ||
		     atomic_test_bit(smp->flags, SMP_FLAG_KEYS_DISTR))) {
			bt_keys_clear(smp->chan.chan.conn->le.keys);
			smp->chan.chan.conn->le.keys = NULL;
		}