mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(wifi): fix esp_wifi_scan_start memory leakage issue
Closes https://github.com/espressif/esp-idf/issues/10693
This commit is contained in:
parent
247cb8b72f
commit
0bfa176435
@ -706,6 +706,7 @@ static esp_err_t update_wifi_scan_results(void)
|
|||||||
prov_ctx->ap_list[curr_channel] = (wifi_ap_record_t *) calloc(get_count, sizeof(wifi_ap_record_t));
|
prov_ctx->ap_list[curr_channel] = (wifi_ap_record_t *) calloc(get_count, sizeof(wifi_ap_record_t));
|
||||||
if (!prov_ctx->ap_list[curr_channel]) {
|
if (!prov_ctx->ap_list[curr_channel]) {
|
||||||
ESP_LOGE(TAG, "Failed to allocate memory for AP list");
|
ESP_LOGE(TAG, "Failed to allocate memory for AP list");
|
||||||
|
esp_wifi_clear_ap_list();
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
if (esp_wifi_scan_get_ap_records(&get_count, prov_ctx->ap_list[curr_channel]) != ESP_OK) {
|
if (esp_wifi_scan_get_ap_records(&get_count, prov_ctx->ap_list[curr_channel]) != ESP_OK) {
|
||||||
|
@ -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
|
||||||
*/
|
*/
|
||||||
@ -63,13 +63,10 @@ static void handle_wnm_scan_done(struct wpa_supplicant *wpa_s)
|
|||||||
|
|
||||||
static void scan_done_cleanup(struct wpa_supplicant *wpa_s)
|
static void scan_done_cleanup(struct wpa_supplicant *wpa_s)
|
||||||
{
|
{
|
||||||
uint16_t number = 1;
|
|
||||||
wifi_ap_record_t ap_records;
|
|
||||||
|
|
||||||
wpa_s->scanning = 0;
|
wpa_s->scanning = 0;
|
||||||
wpa_s->scan_reason = 0;
|
wpa_s->scan_reason = 0;
|
||||||
/* clean scan list from net80211 */
|
/* clean scan list from net80211 */
|
||||||
esp_wifi_scan_get_ap_records(&number, &ap_records);
|
esp_wifi_clear_ap_list();
|
||||||
}
|
}
|
||||||
|
|
||||||
void esp_supplicant_handle_scan_done_evt(void)
|
void esp_supplicant_handle_scan_done_evt(void)
|
||||||
|
@ -210,6 +210,7 @@ static void wifi_event_handler(void* arg, esp_event_base_t event_base,
|
|||||||
wifi_ap_record_t *ap_list = (wifi_ap_record_t *)malloc(sizeof(wifi_ap_record_t) * apCount);
|
wifi_ap_record_t *ap_list = (wifi_ap_record_t *)malloc(sizeof(wifi_ap_record_t) * apCount);
|
||||||
if (!ap_list) {
|
if (!ap_list) {
|
||||||
BLUFI_ERROR("malloc error, ap_list is NULL");
|
BLUFI_ERROR("malloc error, ap_list is NULL");
|
||||||
|
esp_wifi_clear_ap_list();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&apCount, ap_list));
|
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&apCount, ap_list));
|
||||||
|
@ -300,6 +300,7 @@ static bool wifi_perform_scan(const char *ssid, bool internal)
|
|||||||
g_ap_list_buffer = malloc(g_scan_ap_num * sizeof(wifi_ap_record_t));
|
g_ap_list_buffer = malloc(g_scan_ap_num * sizeof(wifi_ap_record_t));
|
||||||
if (g_ap_list_buffer == NULL) {
|
if (g_ap_list_buffer == NULL) {
|
||||||
ESP_LOGE(TAG_STA, "Failed to malloc buffer to print scan results");
|
ESP_LOGE(TAG_STA, "Failed to malloc buffer to print scan results");
|
||||||
|
esp_wifi_clear_ap_list();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ static void scan_done_handler(void *arg, esp_event_base_t event_base,
|
|||||||
ap_list_buffer = malloc(sta_number * sizeof(wifi_ap_record_t));
|
ap_list_buffer = malloc(sta_number * sizeof(wifi_ap_record_t));
|
||||||
if (ap_list_buffer == NULL) {
|
if (ap_list_buffer == NULL) {
|
||||||
ESP_LOGE(TAG, "Failed to malloc buffer to print scan results");
|
ESP_LOGE(TAG, "Failed to malloc buffer to print scan results");
|
||||||
|
esp_wifi_clear_ap_list();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,9 +304,7 @@ void neighbor_report_recv_cb(void *ctx, const uint8_t *report, size_t report_len
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
/* cleanup from net802.11 */
|
/* cleanup from net802.11 */
|
||||||
uint16_t number = 1;
|
esp_wifi_clear_ap_list();
|
||||||
wifi_ap_record_t ap_records;
|
|
||||||
esp_wifi_scan_get_ap_records(&number, &ap_records);
|
|
||||||
cand_list = 1;
|
cand_list = 1;
|
||||||
}
|
}
|
||||||
/* send AP btm query, this will cause STA to roam as well */
|
/* send AP btm query, this will cause STA to roam as well */
|
||||||
|
Loading…
Reference in New Issue
Block a user