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

This commit is contained in:
baohongde 2019-04-24 11:30:04 +08:00
parent 554a28e8a1
commit 39dbe7daa8

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) {