From c9f2790474b5bb959fbba03b0b81527d5619d285 Mon Sep 17 00:00:00 2001 From: aditi_lonkar Date: Tue, 23 Mar 2021 11:09:52 +0530 Subject: [PATCH] wpa_supplicant: Fix some memory leak issues by coverity static analyzer. --- components/wpa_supplicant/src/common/sae.c | 6 ++++-- components/wpa_supplicant/src/esp_supplicant/esp_wpa2.c | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/components/wpa_supplicant/src/common/sae.c b/components/wpa_supplicant/src/common/sae.c index e63aa75954..19853eb139 100644 --- a/components/wpa_supplicant/src/common/sae.c +++ b/components/wpa_supplicant/src/common/sae.c @@ -667,7 +667,7 @@ static int sae_derive_commit_element_ffc(struct sae_data *sae, static int sae_derive_commit(struct sae_data *sae) { - struct crypto_bignum *mask; + struct crypto_bignum *mask = NULL; int ret = -1; unsigned int counter = 0; @@ -682,7 +682,9 @@ static int sae_derive_commit(struct sae_data *sae) */ return ESP_FAIL; } - + if (mask) { + crypto_bignum_deinit(mask, 1); + } mask = sae_get_rand_and_mask(sae); if (mask == NULL) { wpa_printf(MSG_DEBUG, "SAE: Could not get rand/mask"); diff --git a/components/wpa_supplicant/src/esp_supplicant/esp_wpa2.c b/components/wpa_supplicant/src/esp_supplicant/esp_wpa2.c index 1ec6192d1b..e56362e333 100644 --- a/components/wpa_supplicant/src/esp_supplicant/esp_wpa2.c +++ b/components/wpa_supplicant/src/esp_supplicant/esp_wpa2.c @@ -749,8 +749,9 @@ static int eap_peer_sm_init(void) s_wpa2_data_lock = xSemaphoreCreateRecursiveMutex(); if (!s_wpa2_data_lock) { - wpa_printf(MSG_ERROR, "wpa2 eap_peer_sm_init: failed to alloc data lock"); // NOLINT(clang-analyzer-unix.Malloc) - return ESP_ERR_NO_MEM; + free(sm); + wpa_printf(MSG_ERROR, "wpa2 eap_peer_sm_init: failed to alloc data lock"); + return ESP_ERR_NO_MEM; } wpa2_set_eap_state(WPA2_ENT_EAP_STATE_NOT_START);