Skip to content

Commit 035ba19

Browse files
committed
Bluetooth: Controller: Fix missing connection handle invalidate
Fix missing connection handle invalidate on Controller power up. The connection context are zero-initialized on startup and calls to `ll_connected_get()` would incorrectly return a valid connection context pointer for connection handle 0. Relates to commit fa02dc4 ("Bluetooth: Controller: Fix missing reset of connection handle"). Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent c2c1495 commit 035ba19

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

subsys/bluetooth/controller/ll_sw/ull_conn.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ int ull_conn_reset(void)
781781
(void)ull_central_reset();
782782
#endif /* CONFIG_BT_CENTRAL */
783783

784+
/* Stop any active ticker related to connection roles */
784785
for (handle = 0U; handle < CONFIG_BT_MAX_CONN; handle++) {
785786
disable(handle);
786787
}
@@ -1667,6 +1668,14 @@ static int init_reset(void)
16671668
mem_init(conn_pool, sizeof(struct ll_conn),
16681669
sizeof(conn_pool) / sizeof(struct ll_conn), &conn_free);
16691670

1671+
/* Invalidate connection handles, refer to ll_connected_get() */
1672+
for (uint16_t handle = 0U; handle < CONFIG_BT_MAX_CONN; handle++) {
1673+
struct ll_conn *conn;
1674+
1675+
conn = ll_conn_get(handle);
1676+
conn->lll.handle = LLL_HANDLE_INVALID;
1677+
}
1678+
16701679
/* Initialize tx pool. */
16711680
mem_init(mem_conn_tx.pool, CONN_TX_BUF_SIZE, CONN_DATA_BUFFERS,
16721681
&mem_conn_tx.free);
@@ -1836,7 +1845,6 @@ static inline void disable(uint16_t handle)
18361845
conn, &conn->lll);
18371846
LL_ASSERT_INFO2(err == 0 || err == -EALREADY, handle, err);
18381847

1839-
conn->lll.handle = LLL_HANDLE_INVALID;
18401848
conn->lll.link_tx_free = NULL;
18411849
}
18421850

0 commit comments

Comments
 (0)