Fixed some memory was not released after bluetooth controller initialization failed on ESP32

pull/10984/head
zwj 2022-12-07 11:37:22 +08:00
rodzic 56efeb2c76
commit 13493a6137
2 zmienionych plików z 21 dodań i 27 usunięć

Wyświetl plik

@ -324,6 +324,7 @@ static void *customer_queue_create_hlevel_wrapper(uint32_t queue_len, uint32_t i
#endif /* CONFIG_BTDM_CTRL_HLI */
static void IRAM_ATTR interrupt_l3_disable(void);
static void IRAM_ATTR interrupt_l3_restore(void);
static void bt_controller_deinit_internal(void);
/* Local variable definition
***************************************************************************
@ -1575,26 +1576,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
return ESP_OK;
error:
#ifdef CONFIG_PM_ENABLE
if (!s_btdm_allow_light_sleep) {
if (s_light_sleep_pm_lock != NULL) {
esp_pm_lock_delete(s_light_sleep_pm_lock);
s_light_sleep_pm_lock = NULL;
}
}
if (s_pm_lock != NULL) {
esp_pm_lock_delete(s_pm_lock);
s_pm_lock = NULL;
}
if (s_btdm_slp_tmr != NULL) {
esp_timer_delete(s_btdm_slp_tmr);
s_btdm_slp_tmr = NULL;
}
#endif
if (s_wakeup_req_sem) {
semphr_delete_wrapper(s_wakeup_req_sem);
s_wakeup_req_sem = NULL;
}
bt_controller_deinit_internal();
return err;
}
@ -1606,6 +1590,13 @@ esp_err_t esp_bt_controller_deinit(void)
btdm_controller_deinit();
bt_controller_deinit_internal();
return ESP_OK;
}
static void bt_controller_deinit_internal(void)
{
periph_module_disable(PERIPH_BT_MODULE);
#ifdef CONFIG_PM_ENABLE
@ -1627,11 +1618,16 @@ esp_err_t esp_bt_controller_deinit(void)
s_pm_lock_acquired = false;
#endif
semphr_delete_wrapper(s_wakeup_req_sem);
s_wakeup_req_sem = NULL;
free(osi_funcs_p);
osi_funcs_p = NULL;
if (s_wakeup_req_sem) {
semphr_delete_wrapper(s_wakeup_req_sem);
s_wakeup_req_sem = NULL;
}
if (osi_funcs_p) {
free(osi_funcs_p);
osi_funcs_p = NULL;
}
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
@ -1641,8 +1637,6 @@ esp_err_t esp_bt_controller_deinit(void)
esp_bt_power_domain_off();
esp_phy_modem_deinit();
return ESP_OK;
}
static void bt_controller_shutdown(void* arg)

@ -1 +1 @@
Subproject commit dbaeb136cacf8c7d071f838c1053f90299f57720
Subproject commit 9c5686aaa35436d255459312b14fb0da339c656a