Skip to content

Commit

Permalink
Merge branch 'bugfix/dpp_auth_deinit_crash_v50' into 'release/v5.0'
Browse files Browse the repository at this point in the history
Ensure dpp auth structure is deinited in dpp task context(v5.0)

See merge request espressif/esp-idf!29837
  • Loading branch information
jack0c committed Apr 3, 2024
2 parents c73e7c6 + 969605c commit 2fcd97d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
38 changes: 29 additions & 9 deletions components/wpa_supplicant/esp_supplicant/src/esp_dpp.c
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -63,20 +63,31 @@ static int esp_dpp_post_evt(uint32_t evt_id, uint32_t data)
if (evt_id != SIG_DPP_DEL_TASK) {
DPP_API_UNLOCK();
}
wpa_printf(MSG_DEBUG,"DPP: Sent event %d to DPP task", evt_id);

return ret;
end:
if (evt) {
os_free(evt);
}
wpa_printf(MSG_ERROR,"DPP: Failed to send event %d to DPP task", evt_id);
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)
{
if ( evt == ESP_SUPP_DPP_FAIL && s_dpp_ctx.dpp_auth) {
dpp_auth_deinit(s_dpp_ctx.dpp_auth);
s_dpp_ctx.dpp_auth = NULL;
esp_dpp_deinit_auth();
}
s_dpp_ctx.dpp_event_cb(evt, data);
}
Expand All @@ -88,10 +99,6 @@ static void esp_dpp_auth_conf_wait_timeout(void *eloop_ctx, void *timeout_ctx)

wpa_printf(MSG_DEBUG,
"DPP: Terminate authentication exchange due to Auth Confirm timeout");
if (s_dpp_ctx.dpp_auth) {
dpp_auth_deinit(s_dpp_ctx.dpp_auth);
s_dpp_ctx.dpp_auth = NULL;
}
esp_dpp_call_cb(ESP_SUPP_DPP_FAIL, (void *)ESP_ERR_DPP_AUTH_TIMEOUT);
}

Expand Down Expand Up @@ -227,8 +234,9 @@ static int esp_dpp_handle_config_obj(struct dpp_authentication *auth,
wpa_printf(MSG_INFO, DPP_EVENT_CONNECTOR "%s",
conf->connector);
}
s_dpp_listen_in_progress = true;
esp_wifi_action_tx_req(WIFI_OFFCHAN_TX_CANCEL, 0, 0, NULL);
if (s_dpp_listen_in_progress) {
esp_supp_dpp_stop_listen();
}
esp_dpp_call_cb(ESP_SUPP_DPP_CFG_RECVD, wifi_cfg);

return 0;
Expand Down Expand Up @@ -438,6 +446,15 @@ static void esp_dpp_task(void *pvParameters )
}
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:
break;
}
Expand Down Expand Up @@ -508,6 +525,9 @@ static void offchan_event_handler(void *arg, esp_event_base_t event_base,

if (evt->status) {
eloop_cancel_timeout(esp_dpp_auth_conf_wait_timeout, NULL, NULL);
if (s_dpp_listen_in_progress) {
esp_supp_dpp_stop_listen();
}
esp_dpp_call_cb(ESP_SUPP_DPP_FAIL, (void *)ESP_ERR_DPP_TX_FAILURE);
}

Expand Down
1 change: 1 addition & 0 deletions components/wpa_supplicant/esp_supplicant/src/esp_dpp_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ enum SIG_DPP {
SIG_DPP_RX_ACTION,
SIG_DPP_LISTEN_NEXT_CHANNEL,
SIG_DPP_DEL_TASK,
SIG_DPP_DEINIT_AUTH,
SIG_DPP_MAX,
};

Expand Down

0 comments on commit 2fcd97d

Please sign in to comment.