Skip to content

Commit 84811d5

Browse files
Vudentznashif
authored andcommitted
Bluetooth: conn: Fix invalid state transition
When initiating a disconnection conn_disconnect would be called to send HCI_Disconnect but the controller may be quick enough to send Disconnect Complete event before setting BT_CONN_DISCONNECT which will then cause the invalid transition from BT_CONN_DISCONNECTED to BT_CONN_DISCONNECT and the connection won't be freed properly. Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent a0d6f30 commit 84811d5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

subsys/bluetooth/host/conn.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2041,7 +2041,9 @@ static int conn_disconnect(struct bt_conn *conn, uint8_t reason)
20412041
return err;
20422042
}
20432043

2044-
bt_conn_set_state(conn, BT_CONN_DISCONNECT);
2044+
if (conn->state == BT_CONN_CONNECTED) {
2045+
bt_conn_set_state(conn, BT_CONN_DISCONNECT);
2046+
}
20452047

20462048
return 0;
20472049
}

0 commit comments

Comments
 (0)