Skip to content

Commit

Permalink
ble(fix): deinit crash issue
Browse files Browse the repository at this point in the history
  • Loading branch information
luomanruo committed Nov 21, 2023
1 parent 8f44bee commit b7b042f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
7 changes: 4 additions & 3 deletions components/bt/controller/esp32c2/bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
#endif // CONFIG_BT_CONTROLLER_LOG_DUMP
if (ret != ESP_OK) {
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret);
goto modem_deint;
goto controller_init_err;
}
#endif // CONFIG_BT_CONTROLLER_LOG_ENABLED

Expand All @@ -691,11 +691,12 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
return ESP_OK;
free_controller:
controller_sleep_deinit();
modem_deint:
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
controller_init_err:
ble_log_deinit_async();
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
ble_controller_deinit();
modem_deint:
esp_phy_modem_deinit();
periph_module_disable(PERIPH_BT_MODULE);
#if CONFIG_BT_NIMBLE_ENABLED
Expand All @@ -719,10 +720,10 @@ esp_err_t esp_bt_controller_deinit(void)

controller_sleep_deinit();

ble_controller_deinit();
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
ble_log_deinit_async();
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
ble_controller_deinit();

periph_module_disable(PERIPH_BT_MODULE);

Expand Down
9 changes: 5 additions & 4 deletions components/bt/controller/esp32c6/bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
#endif // CONFIG_BT_CONTROLLER_LOG_DUMP
if (ret != ESP_OK) {
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret);
goto modem_deint;
goto controller_init_err;
}
#endif // CONFIG_BT_CONTROLLER_LOG_ENABLED

Expand Down Expand Up @@ -825,12 +825,13 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)

free_controller:
controller_sleep_deinit();
os_msys_deinit();
modem_deint:
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
controller_init_err:
ble_log_deinit_async();
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
os_msys_deinit();
ble_controller_deinit();
modem_deint:
esp_phy_modem_deinit();
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
modem_clock_module_disable(PERIPH_BT_MODULE);
Expand Down Expand Up @@ -861,10 +862,10 @@ esp_err_t esp_bt_controller_deinit(void)
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
modem_clock_module_disable(PERIPH_BT_MODULE);

ble_controller_deinit();
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
ble_log_deinit_async();
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
ble_controller_deinit();

#if CONFIG_BT_NIMBLE_ENABLED
/* De-initialize default event queue */
Expand Down
9 changes: 5 additions & 4 deletions components/bt/controller/esp32h2/bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
#endif // CONFIG_BT_CONTROLLER_LOG_DUMP
if (ret != ESP_OK) {
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret);
goto modem_deint;
goto controller_init_err;
}
#endif // CONFIG_BT_CONTROLLER_LOG_ENABLED

Expand Down Expand Up @@ -806,12 +806,13 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)

free_controller:
controller_sleep_deinit();
os_msys_deinit();
modem_deint:
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
controller_init_err:
ble_log_deinit_async();
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
os_msys_deinit();
ble_controller_deinit();
modem_deint:
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
modem_clock_module_disable(PERIPH_BT_MODULE);
#if CONFIG_BT_NIMBLE_ENABLED
Expand Down Expand Up @@ -840,10 +841,10 @@ esp_err_t esp_bt_controller_deinit(void)
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
modem_clock_module_disable(PERIPH_BT_MODULE);

ble_controller_deinit();
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
ble_log_deinit_async();
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
ble_controller_deinit();

#if CONFIG_BT_NIMBLE_ENABLED
/* De-initialize default event queue */
Expand Down
2 changes: 1 addition & 1 deletion components/bt/controller/lib_esp32c6/esp32c6-bt-lib
2 changes: 1 addition & 1 deletion components/bt/controller/lib_esp32h2/esp32h2-bt-lib

0 comments on commit b7b042f

Please sign in to comment.