Commit f25fe598 authored by Lyle Zhu's avatar Lyle Zhu Committed by Benjamin Cabé
Browse files

Bluetooth: Classic: SMP: Recovery flag SMP_FLAG_BR_CONNECTED

The flag `SMP_FLAG_BR_CONNECTED` is cleared by the function
`smp_br_reset()` and `smp_br_init`. But the flag
`SMP_FLAG_BR_CONNECTED` should not be cleared at this time.

Recovery the flag `SMP_FLAG_BR_CONNECTED` after the all flags of SMP
cleared.

Signed-off-by: default avatarLyle Zhu <lyle.zhu@nxp.com>
parent b59bc363
Loading
Loading
Loading
Loading
+14 −0
Changes for subsys/bluetooth/host/smp.c: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -809,11 +809,18 @@ static void sc_derive_link_key(struct bt_smp *smp)

static void smp_br_reset(struct bt_smp_br *smp)
{
	bool br_smp_connected;

	br_smp_connected = atomic_test_bit(smp->flags, SMP_FLAG_BR_CONNECTED);

	/* Clear flags first in case canceling of timeout fails. The SMP context
	 * shall be marked as timed out in that case.
	 */
	atomic_set(smp->flags, 0);

	/* Set back the status of the flag SMP_FLAG_BR_CONNECTED. */
	atomic_set_bit_to(smp->flags, SMP_FLAG_BR_CONNECTED, br_smp_connected);

	/* If canceling fails the timeout handler will set the timeout flag and
	 * mark the it as timed out. No new pairing procedures shall be started
	 * on this connection if that happens.
@@ -964,11 +971,18 @@ static void bt_smp_br_disconnected(struct bt_l2cap_chan *chan)

static void smp_br_init(struct bt_smp_br *smp)
{
	bool br_smp_connected;

	br_smp_connected = atomic_test_bit(smp->flags, SMP_FLAG_BR_CONNECTED);

	/* Initialize SMP context excluding L2CAP channel context and anything
	 * else declared after.
	 */
	(void)memset(smp, 0, offsetof(struct bt_smp_br, chan));

	/* Set back the status of the flag SMP_FLAG_BR_CONNECTED. */
	atomic_set_bit_to(smp->flags, SMP_FLAG_BR_CONNECTED, br_smp_connected);

	atomic_set_bit(smp->allowed_cmds, BT_SMP_CMD_PAIRING_FAIL);
}