mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-10-07 23:27:23 +00:00
fix(nimble) Free controller memory if init fails
This commit is contained in:
@@ -181,6 +181,11 @@ nimble_port_init(void)
|
||||
|
||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
||||
if (ret != ESP_OK) {
|
||||
// Deinit to free any memory the controller is using.
|
||||
if(esp_bt_controller_deinit() != ESP_OK) {
|
||||
ESP_LOGE(NIMBLE_PORT_LOG_TAG, "controller deinit failed\n");
|
||||
}
|
||||
|
||||
ESP_LOGE(NIMBLE_PORT_LOG_TAG, "controller enable failed\n");
|
||||
return ret;
|
||||
}
|
||||
@@ -188,7 +193,19 @@ nimble_port_init(void)
|
||||
|
||||
ret = esp_nimble_init();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(NIMBLE_PORT_LOG_TAG, "nimble host init failed\n");
|
||||
|
||||
#if CONFIG_BT_CONTROLLER_ENABLED
|
||||
// Disable and deinit controller to free memory
|
||||
if(esp_bt_controller_disable() != ESP_OK) {
|
||||
ESP_LOGE(NIMBLE_PORT_LOG_TAG, "controller disable failed\n");
|
||||
}
|
||||
|
||||
if(esp_bt_controller_deinit() != ESP_OK) {
|
||||
ESP_LOGE(NIMBLE_PORT_LOG_TAG, "controller deinit failed\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
ESP_LOGE(NIMBLE_PORT_LOG_TAG, "nimble host init failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user