Skip to content

Commit fddaaef

Browse files
fix phy init memory leak
1 parent 63a7a84 commit fddaaef

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

components/esp_wifi/src/phy_init.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ const esp_phy_init_data_t* esp_phy_get_init_data(void)
352352
PHY_INIT_MAGIC, sizeof(phy_init_magic_post)) != 0) {
353353
#ifndef CONFIG_ESP32_PHY_DEFAULT_INIT_IF_INVALID
354354
ESP_LOGE(TAG, "failed to validate PHY data partition");
355+
free(init_data_store);
355356
return NULL;
356357
#else
357358
ESP_LOGE(TAG, "failed to validate PHY data partition, restoring default data into flash...");
@@ -855,18 +856,19 @@ esp_err_t esp_phy_update_country_info(const char *country)
855856
{
856857
#if CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN
857858
uint8_t phy_init_data_type_map = 0;
858-
//if country equal s_phy_current_country, return;
859-
if (!memcmp(country, s_phy_current_country, sizeof(s_phy_current_country))) {
860-
return ESP_OK;
861-
}
862-
863-
memcpy(s_phy_current_country, country, sizeof(s_phy_current_country));
864859

865860
if (!s_multiple_phy_init_data_bin) {
866861
ESP_LOGD(TAG, "Does not support multiple PHY init data bins");
867862
return ESP_FAIL;
868863
}
869864

865+
//if country equal s_phy_current_country, return;
866+
if (!memcmp(country, s_phy_current_country, sizeof(s_phy_current_country))) {
867+
return ESP_OK;
868+
}
869+
870+
memcpy(s_phy_current_country, country, sizeof(s_phy_current_country));
871+
870872
phy_init_data_type_map = phy_find_bin_type_according_country(country);
871873
if (phy_init_data_type_map == s_phy_init_data_type) {
872874
return ESP_OK;

0 commit comments

Comments
 (0)