diff mbox series

wpa_supplicant: Free config only if it was allocated in same call

Message ID 001a113d0fa8bb8aa705641bc3b5@google.com
State Accepted
Headers show
Series wpa_supplicant: Free config only if it was allocated in same call | expand

Commit Message

Dmitry Shmidt Feb. 1, 2018, 12:34 a.m. UTC
From 15cce845a258b4c8040f6854f664761654a9f1cb Mon Sep 17 00:00:00 2001
From: Dmitry Shmidt <dimitrysh@google.com>
Date: Wed, 31 Jan 2018 16:27:46 -0800
Subject: [PATCH] wpa_supplicant: Free config only if it was allocated in  
same
  call
To: hostap@lists.infradead.org

If option -I:config points to non-existing file, there
is no need to free the previousely allocated config.

Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
---
  wpa_supplicant/config_file.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jouni Malinen Feb. 4, 2018, 11:14 a.m. UTC | #1
On Thu, Feb 01, 2018 at 12:34:54AM +0000, dimitrysh@google.com wrote:
> If option -I:config points to non-existing file, there
> is no need to free the previousely allocated config.

Thanks, applied (and also fixed the case where the -I config file
exists, but parsing it fails).
diff mbox series

Patch

diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index 6f2161ea6..bf0ba173c 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -397,7 +397,8 @@  struct wpa_config * wpa_config_read(const char *name,  
struct wpa_config *cfgp)
  	if (f == NULL) {
  		wpa_printf(MSG_ERROR, "Failed to open config file '%s', "
  			   "error: %s", name, strerror(errno));
-		os_free(config);
+		if (config != cfgp)
+			os_free(config);
  		return NULL;
  	}