mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 19:24:33 +02:00
fix(bt/bluedroid): fixed access NULL in HFP callback handler
This commit is contained in:
@@ -316,6 +316,10 @@ bt_status_t btc_hf_init(void)
|
|||||||
{
|
{
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
|
|
||||||
|
#if HFP_DYNAMIC_MEMORY == TRUE
|
||||||
|
if (hf_local_param)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
if (hf_local_param[idx].btc_hf_cb.initialized) {
|
if (hf_local_param[idx].btc_hf_cb.initialized) {
|
||||||
esp_hf_cb_param_t param = {
|
esp_hf_cb_param_t param = {
|
||||||
.prof_stat.state = ESP_HF_INIT_ALREADY,
|
.prof_stat.state = ESP_HF_INIT_ALREADY,
|
||||||
@@ -323,6 +327,7 @@ bt_status_t btc_hf_init(void)
|
|||||||
btc_hf_cb_to_app(ESP_HF_PROF_STATE_EVT, ¶m);
|
btc_hf_cb_to_app(ESP_HF_PROF_STATE_EVT, ¶m);
|
||||||
return BT_STATUS_SUCCESS;
|
return BT_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BTC_TRACE_DEBUG("%s - max_hf_clients=%d", __func__, btc_max_hf_clients);
|
BTC_TRACE_DEBUG("%s - max_hf_clients=%d", __func__, btc_max_hf_clients);
|
||||||
|
|
||||||
@@ -364,6 +369,11 @@ void btc_hf_deinit(void)
|
|||||||
BTC_TRACE_EVENT("%s", __FUNCTION__);
|
BTC_TRACE_EVENT("%s", __FUNCTION__);
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
|
|
||||||
|
#if HFP_DYNAMIC_MEMORY == TRUE
|
||||||
|
if (hf_local_param)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
if (!hf_local_param[idx].btc_hf_cb.initialized) {
|
if (!hf_local_param[idx].btc_hf_cb.initialized) {
|
||||||
esp_hf_cb_param_t param = {
|
esp_hf_cb_param_t param = {
|
||||||
.prof_stat.state = ESP_HF_DEINIT_ALREADY,
|
.prof_stat.state = ESP_HF_DEINIT_ALREADY,
|
||||||
@@ -371,6 +381,7 @@ void btc_hf_deinit(void)
|
|||||||
btc_hf_cb_to_app(ESP_HF_PROF_STATE_EVT, ¶m);
|
btc_hf_cb_to_app(ESP_HF_PROF_STATE_EVT, ¶m);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
btc_dm_disable_service(BTA_HFP_SERVICE_ID);
|
btc_dm_disable_service(BTA_HFP_SERVICE_ID);
|
||||||
}
|
}
|
||||||
@@ -1285,12 +1296,17 @@ void btc_hf_cb_handler(btc_msg_t *msg)
|
|||||||
case BTA_AG_DISABLE_EVT:
|
case BTA_AG_DISABLE_EVT:
|
||||||
{
|
{
|
||||||
idx = 0;
|
idx = 0;
|
||||||
btc_hf_cb_release();
|
#if HFP_DYNAMIC_MEMORY == TRUE
|
||||||
|
if (hf_local_param)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
if (hf_local_param[idx].btc_hf_cb.initialized) {
|
if (hf_local_param[idx].btc_hf_cb.initialized) {
|
||||||
|
hf_local_param[idx].btc_hf_cb.initialized = false;
|
||||||
|
btc_hf_cb_release();
|
||||||
param.prof_stat.state = ESP_HF_DEINIT_SUCCESS;
|
param.prof_stat.state = ESP_HF_DEINIT_SUCCESS;
|
||||||
btc_hf_cb_to_app(ESP_HF_PROF_STATE_EVT, ¶m);
|
btc_hf_cb_to_app(ESP_HF_PROF_STATE_EVT, ¶m);
|
||||||
}
|
}
|
||||||
hf_local_param[idx].btc_hf_cb.initialized = false;
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTA_AG_REGISTER_EVT:
|
case BTA_AG_REGISTER_EVT:
|
||||||
|
Reference in New Issue
Block a user