Skip to content

Commit

Permalink
Assert when malloc user_data fail
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongweichao committed Dec 5, 2022
1 parent 07621fd commit 9d56c4c
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ static void btc_spp_dm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_d
user_data->slot_id = slot->id;
} else {
BTC_TRACE_ERROR("%s unable to malloc user data!", __func__);
assert(0);
}
BTA_JvFreeChannel(slot->scn, BTA_JV_CONN_TYPE_RFCOMM,
(tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, (void *)user_data);
Expand Down Expand Up @@ -608,11 +609,8 @@ static void btc_spp_uninit(void)
user_data->server_status = BTA_JV_SERVER_RUNNING;
user_data->slot_id = spp_local_param.spp_slots[i]->id;
} else {
esp_spp_cb_param_t param;
BTC_TRACE_ERROR("%s unable to malloc user data!", __func__);
param.srv_stop.status = ESP_SPP_NO_RESOURCE;
param.srv_stop.scn = spp_local_param.spp_slots[i]->scn;
btc_spp_cb_to_app(ESP_SPP_SRV_STOP_EVT, &param);
assert(0);
}
BTA_JvFreeChannel(spp_local_param.spp_slots[i]->scn, BTA_JV_CONN_TYPE_RFCOMM,
(tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, (void *)user_data);
Expand Down Expand Up @@ -789,7 +787,7 @@ static void btc_spp_stop_srv(btc_spp_args_t *arg)
}

osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
// [1] find all server
// [1] find all unconnected server
for (i = 1; i <= MAX_RFC_PORTS; i++) {
if (spp_local_param.spp_slots[i] != NULL && !spp_local_param.spp_slots[i]->connected &&
spp_local_param.spp_slots[i]->sdp_handle > 0) {
Expand Down Expand Up @@ -844,11 +842,8 @@ static void btc_spp_stop_srv(btc_spp_args_t *arg)
user_data->server_status = BTA_JV_SERVER_RUNNING;
user_data->slot_id = spp_local_param.spp_slots[i]->id;
} else {
esp_spp_cb_param_t param;
BTC_TRACE_ERROR("%s unable to malloc user data!", __func__);
param.srv_stop.status = ESP_SPP_NO_RESOURCE;
param.srv_stop.scn = spp_local_param.spp_slots[i]->scn;
btc_spp_cb_to_app(ESP_SPP_SRV_STOP_EVT, &param);
assert(0);
}
BTA_JvFreeChannel(spp_local_param.spp_slots[i]->scn, BTA_JV_CONN_TYPE_RFCOMM,
(tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, (void *)user_data);
Expand Down

0 comments on commit 9d56c4c

Please sign in to comment.