From 9c5fe742a25d2361b49051aef5b1ed0083494b6c Mon Sep 17 00:00:00 2001 From: Dmitry Shmidt Date: Thu, 1 Feb 2018 00:34:54 +0000 Subject: [PATCH] wpa_supplicant: Free config only if it was allocated in same call If option -I:config points to a non-existing file, the the previously allocated config must not be freed. Avoid use of freed memory in such an error case by skipping the incorrect freeing operation. Signed-off-by: Dmitry Shmidt --- wpa_supplicant/config_file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; }