From 9e2ae1271dd0e0abb9b062cc1e495cd85057721a Mon Sep 17 00:00:00 2001 From: xiongweichao Date: Wed, 27 Apr 2022 14:43:42 +0800 Subject: [PATCH 1/2] Fix spp crash after calling esp_spp_deinit --- .../bt/host/bluedroid/btc/profile/std/spp/btc_spp.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c b/components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c index b206f80a2a..010a370139 100644 --- a/components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c +++ b/components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c @@ -582,11 +582,6 @@ static void btc_spp_uninit(void) osi_mutex_unlock(&spp_local_param.spp_slot_mutex); } 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) { esp_spp_cb_param_t param; param.uninit.status = ret; @@ -1051,7 +1046,7 @@ void btc_spp_cb_handler(btc_msg_t *msg) } break; case BTA_JV_RFCOMM_WRITE_EVT: - osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); + osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); slot = spp_find_slot_by_handle(p_data->rfc_write.handle); if (!slot) { BTC_TRACE_ERROR("%s unable to find RFCOMM slot!, handle:%d", __func__, p_data->rfc_write.handle); @@ -1256,6 +1251,10 @@ void btc_spp_cb_handler(btc_msg_t *msg) param.uninit.status = ESP_SPP_SUCCESS; BTA_JvFree(); 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 osi_free(spp_local_param_ptr); spp_local_param_ptr = NULL; From d59d373edc0e17aa341a291120590ee7e8c0583f Mon Sep 17 00:00:00 2001 From: xiongweichao Date: Wed, 27 Apr 2022 14:49:39 +0800 Subject: [PATCH 2/2] Fix spp initialization failure without free mutex --- components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c b/components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c index 010a370139..025500407f 100644 --- a/components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c +++ b/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) { 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; break; }