From 712feb1e818c0b894e27e1fc93fd226fd9947fac 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 e414f94319..0319694898 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c @@ -2588,9 +2588,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 a3ad604437..772e1cb1c4 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 }