From 68958a2485c6c73beb141ef66d2207701b8b3379 Mon Sep 17 00:00:00 2001 From: baohongde Date: Wed, 27 Sep 2017 14:57:48 +0800 Subject: [PATCH 1/2] component/bt: Fix bug of memory leak of gatt open and close --- components/bt/bluedroid/stack/l2cap/l2c_utils.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/bt/bluedroid/stack/l2cap/l2c_utils.c b/components/bt/bluedroid/stack/l2cap/l2c_utils.c index 68bc2b58d..a8b7a538c 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_utils.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_utils.c @@ -1506,9 +1506,11 @@ tL2C_CCB *l2cu_allocate_ccb (tL2C_LCB *p_lcb, UINT16 cid) p_ccb->tx_mps = L2CAP_FCR_TX_BUF_SIZE - 32; p_ccb->xmit_hold_q = fixed_queue_new(SIZE_MAX); +#if (CLASSIC_BT_INCLUDED == TRUE) p_ccb->fcrb.srej_rcv_hold_q = fixed_queue_new(SIZE_MAX); p_ccb->fcrb.retrans_q = fixed_queue_new(SIZE_MAX); p_ccb->fcrb.waiting_for_ack_q = fixed_queue_new(SIZE_MAX); +#endif ///CLASSIC_BT_INCLUDED == TRUE p_ccb->cong_sent = FALSE; p_ccb->buff_quota = 2; /* This gets set after config */ @@ -1631,6 +1633,12 @@ void l2cu_release_ccb (tL2C_CCB *p_ccb) fixed_queue_free(p_ccb->xmit_hold_q, osi_free_func); +#if (CLASSIC_BT_INCLUDED == TRUE) + fixed_queue_free(p_ccb->fcrb.srej_rcv_hold_q, osi_free_func); + fixed_queue_free(p_ccb->fcrb.retrans_q, osi_free_func); + fixed_queue_free(p_ccb->fcrb.waiting_for_ack_q, osi_free_func); +#endif ///CLASSIC_BT_INCLUDED == TRUE + p_ccb->xmit_hold_q = NULL; #if (CLASSIC_BT_INCLUDED == TRUE) From 27e1db508d3f1f9b00ce1945b10a58aa0948af23 Mon Sep 17 00:00:00 2001 From: baohongde Date: Thu, 28 Sep 2017 14:41:31 +0800 Subject: [PATCH 2/2] component/bt: Fix bug of function btc_ble_set_rand_addr --- components/bt/bluedroid/stack/l2cap/l2c_utils.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/bt/bluedroid/stack/l2cap/l2c_utils.c b/components/bt/bluedroid/stack/l2cap/l2c_utils.c index a8b7a538c..b40146183 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_utils.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_utils.c @@ -1633,13 +1633,16 @@ void l2cu_release_ccb (tL2C_CCB *p_ccb) fixed_queue_free(p_ccb->xmit_hold_q, osi_free_func); + p_ccb->xmit_hold_q = NULL; #if (CLASSIC_BT_INCLUDED == TRUE) fixed_queue_free(p_ccb->fcrb.srej_rcv_hold_q, osi_free_func); fixed_queue_free(p_ccb->fcrb.retrans_q, osi_free_func); fixed_queue_free(p_ccb->fcrb.waiting_for_ack_q, osi_free_func); + p_ccb->fcrb.srej_rcv_hold_q = NULL; + p_ccb->fcrb.retrans_q = NULL; + p_ccb->fcrb.waiting_for_ack_q = NULL; #endif ///CLASSIC_BT_INCLUDED == TRUE - - p_ccb->xmit_hold_q = NULL; + #if (CLASSIC_BT_INCLUDED == TRUE) l2c_fcr_cleanup (p_ccb);