Skip to content

Commit adae515

Browse files
cvinayakgalak
authored andcommitted
Bluetooth: controller: Fix conn setup regression
Fix incorrect and redundant use of ticker user id ULL_LOW instead of ULL_HIGH when setting up a connection using a mayfly to disable LLL context. Also, the LLL context pointer is invalid, where node rx is passed instead of LLL context. Use the ULL disabled callback when done event has not yet been processed, or a direct connection setup in ULL_HIGH context when ULL is already disabled (reference count is zero) is sufficient. Regression introduced in commit 30f260d ("Bluetooth: controller: Fix adv/scan context access post release"). Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent c2efcc3 commit adae515

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

subsys/bluetooth/controller/ll_sw/ull_conn.c

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -820,25 +820,19 @@ bool ull_conn_peer_connected(uint8_t own_addr_type, uint8_t *own_addr,
820820

821821
void ull_conn_setup(memq_link_t *rx_link, struct node_rx_hdr *rx)
822822
{
823-
static memq_link_t link;
824-
static struct mayfly mfy = {0, 0, &link, NULL, NULL};
825823
struct node_rx_ftr *ftr;
826824
struct lll_conn *lll;
827825
struct ull_hdr *hdr;
828826

829-
/* Pass the node rx as mayfly function parameter */
830-
mfy.param = rx;
831-
832827
/* Store the link in the node rx so that when done event is
833828
* processed it can be used to enqueue node rx towards LL context
834829
*/
835830
rx->link = rx_link;
836831

837-
ftr = &(rx->rx_ftr);
838-
839832
/* NOTE: LLL conn context SHALL be after lll_hdr in
840833
* struct lll_adv and struct lll_scan.
841834
*/
835+
ftr = &(rx->rx_ftr);
842836
lll = *((struct lll_conn **)((uint8_t *)ftr->param +
843837
sizeof(struct lll_hdr)));
844838

@@ -847,23 +841,14 @@ void ull_conn_setup(memq_link_t *rx_link, struct node_rx_hdr *rx)
847841
*/
848842
hdr = HDR_LLL2ULL(ftr->param);
849843
if (ull_ref_get(hdr)) {
850-
uint32_t ret;
851-
844+
/* Setup connection in ULL disabled callback,
845+
* pass the node rx as disabled callback parameter.
846+
*/
852847
LL_ASSERT(!hdr->disabled_cb);
853-
hdr->disabled_param = mfy.param;
848+
hdr->disabled_param = rx;
854849
hdr->disabled_cb = conn_setup_adv_scan_disabled_cb;
855-
856-
mfy.fp = lll_disable;
857-
ret = mayfly_enqueue(TICKER_USER_ID_ULL_LOW,
858-
TICKER_USER_ID_LLL, 0, &mfy);
859-
LL_ASSERT(!ret);
860850
} else {
861-
uint32_t ret;
862-
863-
mfy.fp = conn_setup_adv_scan_disabled_cb;
864-
ret = mayfly_enqueue(TICKER_USER_ID_ULL_LOW,
865-
TICKER_USER_ID_ULL_HIGH, 0, &mfy);
866-
LL_ASSERT(!ret);
851+
conn_setup_adv_scan_disabled_cb(rx);
867852
}
868853
}
869854

@@ -1898,12 +1883,11 @@ static void conn_setup_adv_scan_disabled_cb(void *param)
18981883
struct node_rx_hdr *rx;
18991884
struct lll_conn *lll;
19001885

1901-
rx = param;
1902-
ftr = &(rx->rx_ftr);
1903-
19041886
/* NOTE: LLL conn context SHALL be after lll_hdr in
19051887
* struct lll_adv and struct lll_scan.
19061888
*/
1889+
rx = param;
1890+
ftr = &(rx->rx_ftr);
19071891
lll = *((struct lll_conn **)((uint8_t *)ftr->param +
19081892
sizeof(struct lll_hdr)));
19091893
switch (lll->role) {

0 commit comments

Comments
 (0)