From 6d7c9907c316bcc45c2b10bd01abe58d2e498e24 Mon Sep 17 00:00:00 2001 From: wangcheng Date: Mon, 26 Oct 2020 15:56:55 +0800 Subject: [PATCH] components/bt: fixed memory damage caused by bluetooth memory release --- components/bt/controller/bt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/bt/controller/bt.c b/components/bt/controller/bt.c index 808d4b6f07..e4bcf69f02 100644 --- a/components/bt/controller/bt.c +++ b/components/bt/controller/bt.c @@ -1224,6 +1224,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; @@ -1238,11 +1243,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; }