Merge branch 'bugfix/btdm_abort_if_deinit_spp_without_init_v3.2' into 'release/v3.2'

components/bt: Fix abort if call esp_spp_deinit without calling esp_spp_init

See merge request idf/esp-idf!4862
This commit is contained in:
Jiang Jiang Jian 2019-04-26 21:01:35 +08:00
commit 193b8e93a8

View file

@ -315,6 +315,7 @@ static void btc_spp_init(btc_spp_args_t *arg)
{
if (osi_mutex_new(&spp_local_param.spp_slot_mutex) != 0) {
BTC_TRACE_ERROR("%s osi_mutex_new failed\n", __func__);
return;
}
spp_local_param.spp_mode = arg->init.mode;
spp_local_param.spp_slot_id = 0;
@ -323,6 +324,10 @@ static void btc_spp_init(btc_spp_args_t *arg)
static void btc_spp_uninit(void)
{
if (!spp_local_param.spp_slot_mutex) {
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
return;
}
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) {
if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->connected) {