Skip to content

Commit 23bb13d

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. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent ee940cb commit 23bb13d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

subsys/bluetooth/controller/ll_sw/ull_conn.c

Lines changed: 6 additions & 2 deletions
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,11 @@ 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 (handle = 0U; handle < CONFIG_BT_MAX_CONN; handle++) {
1673+
conn->lll.handle = LLL_HANDLE_INVALID;
1674+
}
1675+
16701676
/* Initialize tx pool. */
16711677
mem_init(mem_conn_tx.pool, CONN_TX_BUF_SIZE, CONN_DATA_BUFFERS,
16721678
&mem_conn_tx.free);
@@ -1835,8 +1841,6 @@ static inline void disable(uint16_t handle)
18351841
err = ull_ticker_stop_with_mark(TICKER_ID_CONN_BASE + handle,
18361842
conn, &conn->lll);
18371843
LL_ASSERT_INFO2(err == 0 || err == -EALREADY, handle, err);
1838-
1839-
conn->lll.handle = LLL_HANDLE_INVALID;
18401844
conn->lll.link_tx_free = NULL;
18411845
}
18421846

0 commit comments

Comments
 (0)