mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 20:24:32 +02:00
fix ble connect crash
This commit is contained in:
committed by
zwj
parent
1d1754e4b4
commit
d4619584d7
@@ -888,12 +888,27 @@ void l2c_init (void)
|
|||||||
l2ble_update_att_acl_pkt_num(L2CA_BUFF_INI, NULL);
|
l2ble_update_att_acl_pkt_num(L2CA_BUFF_INI, NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
void l2c_free_p_lcb_pool(void)
|
||||||
|
{
|
||||||
|
list_node_t *p_node = NULL;
|
||||||
|
tL2C_LCB *p_lcb = NULL;
|
||||||
|
for (p_node = list_begin(l2cb.p_lcb_pool); p_node; p_node = list_next(p_node)) {
|
||||||
|
p_lcb = list_node(p_node);
|
||||||
|
if (p_lcb) {
|
||||||
|
l2cu_release_lcb (p_lcb);
|
||||||
|
list_remove(l2cb.p_lcb_pool, p_lcb);
|
||||||
|
osi_free(p_lcb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list_free(l2cb.p_lcb_pool);
|
||||||
|
}
|
||||||
|
|
||||||
void l2c_free(void)
|
void l2c_free(void)
|
||||||
{
|
{
|
||||||
list_free(l2cb.rcv_pending_q);
|
list_free(l2cb.rcv_pending_q);
|
||||||
l2cb.rcv_pending_q = NULL;
|
l2cb.rcv_pending_q = NULL;
|
||||||
list_free(l2cb.p_lcb_pool);
|
l2c_free_p_lcb_pool();
|
||||||
list_free(l2cb.p_ccb_pool);
|
list_free(l2cb.p_ccb_pool);
|
||||||
#if L2C_DYNAMIC_MEMORY
|
#if L2C_DYNAMIC_MEMORY
|
||||||
FREE_AND_RESET(l2c_cb_ptr);
|
FREE_AND_RESET(l2c_cb_ptr);
|
||||||
|
@@ -52,7 +52,13 @@ tL2C_LCB *l2cu_allocate_lcb (BD_ADDR p_bd_addr, BOOLEAN is_bonding, tBT_TRANSPOR
|
|||||||
{
|
{
|
||||||
tL2C_LCB *p_lcb = NULL;
|
tL2C_LCB *p_lcb = NULL;
|
||||||
bool list_ret = false;
|
bool list_ret = false;
|
||||||
if (list_length(l2cb.p_lcb_pool) < MAX_L2CAP_LINKS) {
|
extern tL2C_LCB *l2cu_find_free_lcb (void);
|
||||||
|
// temp solution
|
||||||
|
p_lcb = l2cu_find_free_lcb();
|
||||||
|
if(p_lcb != NULL) {
|
||||||
|
list_ret = true;
|
||||||
|
}
|
||||||
|
if(p_lcb == NULL && list_length(l2cb.p_lcb_pool) < MAX_L2CAP_LINKS) {
|
||||||
p_lcb = (tL2C_LCB *)osi_malloc(sizeof(tL2C_LCB));
|
p_lcb = (tL2C_LCB *)osi_malloc(sizeof(tL2C_LCB));
|
||||||
if (p_lcb) {
|
if (p_lcb) {
|
||||||
memset (p_lcb, 0, sizeof(tL2C_LCB));
|
memset (p_lcb, 0, sizeof(tL2C_LCB));
|
||||||
@@ -272,14 +278,6 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb)
|
|||||||
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
|
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
|
||||||
p_lcb->completed_packets = 0;
|
p_lcb->completed_packets = 0;
|
||||||
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
|
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
|
||||||
{
|
|
||||||
if (list_remove(l2cb.p_lcb_pool, p_lcb)) {
|
|
||||||
p_lcb = NULL;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
L2CAP_TRACE_ERROR("Error in removing L2CAP Link Control Block");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -312,6 +310,20 @@ tL2C_LCB *l2cu_find_lcb_by_bd_addr (BD_ADDR p_bd_addr, tBT_TRANSPORT transport)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tL2C_LCB *l2cu_find_free_lcb (void)
|
||||||
|
{
|
||||||
|
list_node_t *p_node = NULL;
|
||||||
|
tL2C_LCB *p_lcb = NULL;
|
||||||
|
for (p_node = list_begin(l2cb.p_lcb_pool); p_node; p_node = list_next(p_node)) {
|
||||||
|
p_lcb = list_node(p_node);
|
||||||
|
if (!p_lcb->in_use) {
|
||||||
|
return (p_lcb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* If here, no match found */
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
** Function l2cu_get_conn_role
|
** Function l2cu_get_conn_role
|
||||||
|
Reference in New Issue
Block a user