From a2eec8a1e2331bee983dfdc63e8cd2de4ba36783 Mon Sep 17 00:00:00 2001 From: zwj Date: Thu, 17 Sep 2020 14:32:27 +0800 Subject: [PATCH] fix vendor hci memory leak --- components/bt/host/bluedroid/bta/dm/bta_dm_api.c | 4 +--- .../bt/host/bluedroid/stack/btm/btm_ble_multi_adv.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c index aeeadb0983..f47b047a4f 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c @@ -2663,9 +2663,7 @@ void BTA_VendorCleanup (void) } #endif - if (cmn_ble_vsc_cb.adv_inst_max > 0) { - btm_ble_multi_adv_cleanup(); - } + btm_ble_multi_adv_cleanup(); } #endif diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_multi_adv.c b/components/bt/host/bluedroid/stack/btm/btm_ble_multi_adv.c index b18d68e39a..c7b9f06802 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_multi_adv.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_multi_adv.c @@ -840,10 +840,14 @@ void btm_ble_multi_adv_cleanup(void) } #if BTM_DYNAMIC_MEMORY == TRUE - osi_free(btm_multi_adv_cb_ptr); - osi_free(btm_multi_adv_idx_q_ptr); - btm_multi_adv_cb_ptr = NULL; - btm_multi_adv_idx_q_ptr = NULL; + if(btm_multi_adv_cb_ptr) { + osi_free(btm_multi_adv_cb_ptr); + btm_multi_adv_cb_ptr = NULL; + } + if(btm_multi_adv_idx_q_ptr) { + osi_free(btm_multi_adv_idx_q_ptr); + btm_multi_adv_idx_q_ptr = NULL; + } #endif }