Skip to content

Commit 346d236

Browse files
author
Jiang Jiang Jian
committed
Merge branch 'bugfix/stack_corruption_btm_task_v5.1' into 'release/v5.1'
fix(esp_wifi): Fix stack curruption in btm task(v5.1) See merge request espressif/esp-idf!36972
2 parents f0f5b08 + dd740aa commit 346d236

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

components/wpa_supplicant/esp_supplicant/src/esp_common.c

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,22 @@ static int mgmt_rx_action(u8 *frame, size_t len, u8 *sender, int8_t rssi, u8 cha
116116
#ifdef CONFIG_SUPPLICANT_TASK
117117
static void btm_rrm_task(void *pvParameters)
118118
{
119-
supplicant_event_t *evt;
119+
supplicant_event_t evt;
120120
bool task_del = false;
121121

122122
while(1) {
123123
if (os_queue_recv(s_supplicant_evt_queue, &evt, OS_BLOCK) != TRUE)
124124
continue;
125125

126126
/* event validation failed */
127-
if (evt->id >= SIG_SUPPLICANT_MAX) {
128-
os_free(evt);
127+
if (evt.id >= SIG_SUPPLICANT_MAX) {
129128
continue;
130129
}
131130

132-
switch (evt->id) {
131+
switch (evt.id) {
133132
case SIG_SUPPLICANT_RX_ACTION:
134133
{
135-
struct ieee_mgmt_frame *frm = (struct ieee_mgmt_frame *)evt->data;
134+
struct ieee_mgmt_frame *frm = (struct ieee_mgmt_frame *)evt.data;
136135
mgmt_rx_action(frm->payload, frm->len, frm->sender, frm->rssi, frm->channel);
137136
os_free(frm);
138137
break;
@@ -148,8 +147,6 @@ static void btm_rrm_task(void *pvParameters)
148147
break;
149148
}
150149

151-
os_free(evt);
152-
153150
if (task_del)
154151
break;
155152
}
@@ -816,27 +813,21 @@ int wpa_drv_send_action(struct wpa_supplicant *wpa_s,
816813
#ifdef CONFIG_SUPPLICANT_TASK
817814
int esp_supplicant_post_evt(uint32_t evt_id, uint32_t data)
818815
{
819-
supplicant_event_t *evt = os_zalloc(sizeof(supplicant_event_t));
820-
if (!evt) {
821-
wpa_printf(MSG_ERROR, "Failed to allocated memory");
822-
return -1;
823-
}
824-
evt->id = evt_id;
825-
evt->data = data;
816+
supplicant_event_t evt;
817+
evt.id = evt_id;
818+
evt.data = data;
826819

827820
/* Make sure lock exists before taking it */
828821
SUPPLICANT_API_LOCK();
829822

830823
/* Make sure no event can be sent when deletion event is sent or task not initialized */
831824
if (!s_supplicant_task_init_done) {
832825
SUPPLICANT_API_UNLOCK();
833-
os_free(evt);
834826
return -1;
835827
}
836828

837829
if (os_queue_send(s_supplicant_evt_queue, &evt, os_task_ms_to_tick(10)) != TRUE) {
838830
SUPPLICANT_API_UNLOCK();
839-
os_free(evt);
840831
return -1;
841832
}
842833
if (evt_id == SIG_SUPPLICANT_DEL_TASK) {

0 commit comments

Comments
 (0)