@@ -180,19 +180,19 @@ uint16_t ll_conn_handle_get(struct ll_conn *conn)
180
180
181
181
struct ll_conn * ll_conn_get (uint16_t handle )
182
182
{
183
+ if (handle >= CONFIG_BT_MAX_CONN ) {
184
+ return NULL ;
185
+ }
186
+
183
187
return mem_get (conn_pool , sizeof (struct ll_conn ), handle );
184
188
}
185
189
186
190
struct ll_conn * ll_connected_get (uint16_t handle )
187
191
{
188
192
struct ll_conn * conn ;
189
193
190
- if (handle >= CONFIG_BT_MAX_CONN ) {
191
- return NULL ;
192
- }
193
-
194
194
conn = ll_conn_get (handle );
195
- if (conn -> lll .handle != handle ) {
195
+ if (( conn == NULL ) || ( conn -> lll .handle != handle ) ) {
196
196
return NULL ;
197
197
}
198
198
@@ -429,6 +429,7 @@ uint8_t ll_terminate_ind_send(uint16_t handle, uint8_t reason)
429
429
}
430
430
return 0 ;
431
431
}
432
+
432
433
#if defined(CONFIG_BT_CTLR_PERIPHERAL_ISO ) || defined(CONFIG_BT_CTLR_CENTRAL_ISO )
433
434
if (IS_CIS_HANDLE (handle )) {
434
435
cis = ll_iso_stream_connected_get (handle );
@@ -445,6 +446,7 @@ uint8_t ll_terminate_ind_send(uint16_t handle, uint8_t reason)
445
446
446
447
} else if (cis -> group -> state == CIG_STATE_INITIATING ) {
447
448
conn = ll_connected_get (cis -> lll .acl_handle );
449
+ LL_ASSERT (conn != NULL );
448
450
449
451
/* CIS is not yet established - try to cancel procedure */
450
452
if (ull_cp_cc_cancel (conn )) {
@@ -805,6 +807,9 @@ struct lll_conn *ull_conn_lll_get(uint16_t handle)
805
807
struct ll_conn * conn ;
806
808
807
809
conn = ll_conn_get (handle );
810
+ if (conn == NULL ) {
811
+ return NULL ;
812
+ }
808
813
809
814
return & conn -> lll ;
810
815
}
@@ -1553,22 +1558,32 @@ void ull_conn_tx_ack(uint16_t handle, memq_link_t *link, struct node_tx *tx)
1553
1558
if (handle != LLL_HANDLE_INVALID ) {
1554
1559
struct ll_conn * conn = ll_conn_get (handle );
1555
1560
1561
+ LL_ASSERT (conn != NULL );
1562
+
1556
1563
ull_cp_tx_ack (conn , tx );
1557
1564
}
1558
1565
1559
1566
/* release ctrl mem if points to itself */
1560
1567
if (link -> next == (void * )tx ) {
1568
+ struct ll_conn * conn ;
1569
+
1570
+ /* Tx Node not re-used, ensure link->next is non-NULL */
1561
1571
LL_ASSERT (link -> next );
1562
1572
1563
- struct ll_conn * conn = ll_connected_get (handle );
1573
+ conn = ll_connected_get (handle );
1574
+ LL_ASSERT (conn != NULL );
1564
1575
1565
1576
ull_cp_release_tx (conn , tx );
1577
+
1566
1578
return ;
1579
+
1567
1580
} else if (!tx ) {
1568
1581
/* Tx Node re-used to enqueue new ctrl PDU */
1569
1582
return ;
1570
1583
}
1584
+
1571
1585
LL_ASSERT (!link -> next );
1586
+
1572
1587
} else if (handle == LLL_HANDLE_INVALID ) {
1573
1588
pdu_tx -> ll_id = PDU_DATA_LLID_RESV ;
1574
1589
} else {
@@ -1672,6 +1687,7 @@ static int init_reset(void)
1672
1687
for (uint16_t handle = 0U ; handle < CONFIG_BT_MAX_CONN ; handle ++ ) {
1673
1688
struct ll_conn * conn ;
1674
1689
1690
+ /* handle in valid range, conn will be non-NULL */
1675
1691
conn = ll_conn_get (handle );
1676
1692
conn -> lll .handle = LLL_HANDLE_INVALID ;
1677
1693
}
@@ -1840,6 +1856,7 @@ static inline void disable(uint16_t handle)
1840
1856
int err ;
1841
1857
1842
1858
conn = ll_conn_get (handle );
1859
+ LL_ASSERT (conn != NULL );
1843
1860
1844
1861
err = ull_ticker_stop_with_mark (TICKER_ID_CONN_BASE + handle ,
1845
1862
conn , & conn -> lll );
0 commit comments