Browse Source

Component_bt/Fix spp crash after call esp_spp_deinit

Xiong Wei Chao 3 years ago
parent
commit
af84842e8b
1 changed files with 5 additions and 5 deletions
  1. 5 5
      components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c

+ 5 - 5
components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c

@@ -519,6 +519,7 @@ static void btc_spp_init(btc_spp_args_t *arg)
         }
         }
         if ((spp_local_param.tx_event_group = xEventGroupCreate()) == NULL) {
         if ((spp_local_param.tx_event_group = xEventGroupCreate()) == NULL) {
             BTC_TRACE_ERROR("%s create tx_event_group failed\n", __func__);
             BTC_TRACE_ERROR("%s create tx_event_group failed\n", __func__);
+            osi_mutex_free(&spp_local_param.spp_slot_mutex);
             ret = ESP_SPP_NO_RESOURCE;
             ret = ESP_SPP_NO_RESOURCE;
             break;
             break;
         }
         }
@@ -582,11 +583,6 @@ static void btc_spp_uninit(void)
         osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
         osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
     } while(0);
     } while(0);
 
 
-    if (spp_local_param.tx_event_group) {
-        vEventGroupDelete(spp_local_param.tx_event_group);
-        spp_local_param.tx_event_group = NULL;
-    }
-
     if (ret != ESP_SPP_SUCCESS) {
     if (ret != ESP_SPP_SUCCESS) {
         esp_spp_cb_param_t param;
         esp_spp_cb_param_t param;
         param.uninit.status = ret;
         param.uninit.status = ret;
@@ -1256,6 +1252,10 @@ void btc_spp_cb_handler(btc_msg_t *msg)
         param.uninit.status = ESP_SPP_SUCCESS;
         param.uninit.status = ESP_SPP_SUCCESS;
         BTA_JvFree();
         BTA_JvFree();
         osi_mutex_free(&spp_local_param.spp_slot_mutex);
         osi_mutex_free(&spp_local_param.spp_slot_mutex);
+        if (spp_local_param.tx_event_group) {
+            vEventGroupDelete(spp_local_param.tx_event_group);
+            spp_local_param.tx_event_group = NULL;
+        }
 #if SPP_DYNAMIC_MEMORY == TRUE
 #if SPP_DYNAMIC_MEMORY == TRUE
         osi_free(spp_local_param_ptr);
         osi_free(spp_local_param_ptr);
         spp_local_param_ptr = NULL;
         spp_local_param_ptr = NULL;