Merge branch 'bugfix/dpp_auth_deinit_crash_v44' into 'release/v4.4'

Ensure dpp auth structure is deinited in dpp task context(v4.4)

See merge request espressif/esp-idf!29836
This commit is contained in:
Jiang Jiang Jian 2024-04-03 17:29:00 +08:00
commit e1affdc8f7
2 changed files with 27 additions and 5 deletions

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -58,20 +58,31 @@ static int esp_dpp_post_evt(uint32_t evt_id, uint32_t data)
if (evt_id != SIG_DPP_DEL_TASK) { if (evt_id != SIG_DPP_DEL_TASK) {
DPP_API_UNLOCK(); DPP_API_UNLOCK();
} }
wpa_printf(MSG_DEBUG,"DPP: Sent event %d to DPP task", evt_id);
return ret; return ret;
end: end:
if (evt) { if (evt) {
os_free(evt); os_free(evt);
} }
wpa_printf(MSG_ERROR,"DPP: Failed to send event %d to DPP task", evt_id);
return ret; return ret;
} }
static uint8_t esp_dpp_deinit_auth(void)
{
esp_err_t ret = esp_dpp_post_evt(SIG_DPP_DEINIT_AUTH, 0);
if (ESP_OK != ret) {
wpa_printf(MSG_ERROR, "Failed to post DPP auth deinit to DPP Task(status=%d)", ret);
return ret;
}
return ESP_OK;
}
static void esp_dpp_call_cb(esp_supp_dpp_event_t evt, void *data) static void esp_dpp_call_cb(esp_supp_dpp_event_t evt, void *data)
{ {
if ( evt == ESP_SUPP_DPP_FAIL && s_dpp_ctx.dpp_auth) { if ( evt == ESP_SUPP_DPP_FAIL && s_dpp_ctx.dpp_auth) {
dpp_auth_deinit(s_dpp_ctx.dpp_auth); esp_dpp_deinit_auth();
s_dpp_ctx.dpp_auth = NULL;
} }
s_dpp_ctx.dpp_event_cb(evt, data); s_dpp_ctx.dpp_event_cb(evt, data);
} }
@ -205,8 +216,9 @@ static int esp_dpp_handle_config_obj(struct dpp_authentication *auth,
wpa_printf(MSG_INFO, DPP_EVENT_CONNECTOR "%s", wpa_printf(MSG_INFO, DPP_EVENT_CONNECTOR "%s",
conf->connector); conf->connector);
} }
s_dpp_listen_in_progress = true; if (s_dpp_listen_in_progress) {
esp_wifi_action_tx_req(WIFI_OFFCHAN_TX_CANCEL, 0, 0, NULL); esp_supp_dpp_stop_listen();
}
esp_dpp_call_cb(ESP_SUPP_DPP_CFG_RECVD, wifi_cfg); esp_dpp_call_cb(ESP_SUPP_DPP_CFG_RECVD, wifi_cfg);
return 0; return 0;
@ -420,6 +432,15 @@ static void esp_dpp_task(void *pvParameters )
} }
break; break;
case SIG_DPP_DEINIT_AUTH: {
if (s_dpp_ctx.dpp_auth) {
dpp_auth_deinit(s_dpp_ctx.dpp_auth);
s_dpp_ctx.dpp_auth = NULL;
}
wpa_printf(MSG_DEBUG, "DPP auth deinintialized");
}
break;
default: default:
break; break;
} }

View File

@ -23,6 +23,7 @@ enum SIG_DPP {
SIG_DPP_RX_ACTION, SIG_DPP_RX_ACTION,
SIG_DPP_LISTEN_NEXT_CHANNEL, SIG_DPP_LISTEN_NEXT_CHANNEL,
SIG_DPP_DEL_TASK, SIG_DPP_DEL_TASK,
SIG_DPP_DEINIT_AUTH,
SIG_DPP_MAX, SIG_DPP_MAX,
}; };