diff --git a/components/bt/bt.c b/components/bt/bt.c index b0331b9d5b..c1bb13591a 100644 --- a/components/bt/bt.c +++ b/components/bt/bt.c @@ -1124,6 +1124,11 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) esp_err_t err; uint32_t btdm_cfg_mask = 0; + //if all the bt available memory was already released, cannot initialize bluetooth controller + if (btdm_dram_available_region[0].mode == ESP_BT_MODE_IDLE) { + return ESP_ERR_INVALID_STATE; + } + osi_funcs_p = (struct osi_funcs_t *)malloc_internal_wrapper(sizeof(struct osi_funcs_t)); if (osi_funcs_p == NULL) { return ESP_ERR_NO_MEM; @@ -1138,11 +1143,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) return ESP_ERR_INVALID_STATE; } - //if all the bt available memory was already released, cannot initialize bluetooth controller - if (btdm_dram_available_region[0].mode == ESP_BT_MODE_IDLE) { - return ESP_ERR_INVALID_STATE; - } - if (cfg == NULL) { return ESP_ERR_INVALID_ARG; }