Skip to content

Commit f25fe59

Browse files
lylezhu2012kartben
authored andcommitted
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: Lyle Zhu <[email protected]>
1 parent b59bc36 commit f25fe59

File tree

1 file changed

+14
-0
lines changed
  • subsys/bluetooth/host

1 file changed

+14
-0
lines changed

subsys/bluetooth/host/smp.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,11 +809,18 @@ static void sc_derive_link_key(struct bt_smp *smp)
809809

810810
static void smp_br_reset(struct bt_smp_br *smp)
811811
{
812+
bool br_smp_connected;
813+
814+
br_smp_connected = atomic_test_bit(smp->flags, SMP_FLAG_BR_CONNECTED);
815+
812816
/* Clear flags first in case canceling of timeout fails. The SMP context
813817
* shall be marked as timed out in that case.
814818
*/
815819
atomic_set(smp->flags, 0);
816820

821+
/* Set back the status of the flag SMP_FLAG_BR_CONNECTED. */
822+
atomic_set_bit_to(smp->flags, SMP_FLAG_BR_CONNECTED, br_smp_connected);
823+
817824
/* If canceling fails the timeout handler will set the timeout flag and
818825
* mark the it as timed out. No new pairing procedures shall be started
819826
* on this connection if that happens.
@@ -964,11 +971,18 @@ static void bt_smp_br_disconnected(struct bt_l2cap_chan *chan)
964971

965972
static void smp_br_init(struct bt_smp_br *smp)
966973
{
974+
bool br_smp_connected;
975+
976+
br_smp_connected = atomic_test_bit(smp->flags, SMP_FLAG_BR_CONNECTED);
977+
967978
/* Initialize SMP context excluding L2CAP channel context and anything
968979
* else declared after.
969980
*/
970981
(void)memset(smp, 0, offsetof(struct bt_smp_br, chan));
971982

983+
/* Set back the status of the flag SMP_FLAG_BR_CONNECTED. */
984+
atomic_set_bit_to(smp->flags, SMP_FLAG_BR_CONNECTED, br_smp_connected);
985+
972986
atomic_set_bit(smp->allowed_cmds, BT_SMP_CMD_PAIRING_FAIL);
973987
}
974988

0 commit comments

Comments
 (0)