hostapd: Fix early init failure path
eloop deinit calls could trigger segmentation fault if the early error path is hit before eloop_init() gets called. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
976dfb3237
commit
cc27c8e680
2 changed files with 8 additions and 4 deletions
|
@ -339,6 +339,7 @@ static int hostapd_global_init(struct hapd_interfaces *interfaces,
|
||||||
wpa_printf(MSG_ERROR, "Failed to initialize event loop");
|
wpa_printf(MSG_ERROR, "Failed to initialize event loop");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
interfaces->eloop_initialized = 1;
|
||||||
|
|
||||||
random_init(entropy_file);
|
random_init(entropy_file);
|
||||||
|
|
||||||
|
@ -366,7 +367,7 @@ static int hostapd_global_init(struct hapd_interfaces *interfaces,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void hostapd_global_deinit(const char *pid_file)
|
static void hostapd_global_deinit(const char *pid_file, int eloop_initialized)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -384,7 +385,8 @@ static void hostapd_global_deinit(const char *pid_file)
|
||||||
|
|
||||||
random_deinit();
|
random_deinit();
|
||||||
|
|
||||||
eloop_destroy();
|
if (eloop_initialized)
|
||||||
|
eloop_destroy();
|
||||||
|
|
||||||
#ifndef CONFIG_NATIVE_WINDOWS
|
#ifndef CONFIG_NATIVE_WINDOWS
|
||||||
closelog();
|
closelog();
|
||||||
|
@ -816,8 +818,9 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
os_free(interfaces.iface);
|
os_free(interfaces.iface);
|
||||||
|
|
||||||
eloop_cancel_timeout(hostapd_periodic, &interfaces, NULL);
|
if (interfaces.eloop_initialized)
|
||||||
hostapd_global_deinit(pid_file);
|
eloop_cancel_timeout(hostapd_periodic, &interfaces, NULL);
|
||||||
|
hostapd_global_deinit(pid_file, interfaces.eloop_initialized);
|
||||||
os_free(pid_file);
|
os_free(pid_file);
|
||||||
|
|
||||||
if (log_file)
|
if (log_file)
|
||||||
|
|
|
@ -53,6 +53,7 @@ struct hapd_interfaces {
|
||||||
#ifndef CONFIG_NO_VLAN
|
#ifndef CONFIG_NO_VLAN
|
||||||
struct dynamic_iface *vlan_priv;
|
struct dynamic_iface *vlan_priv;
|
||||||
#endif /* CONFIG_NO_VLAN */
|
#endif /* CONFIG_NO_VLAN */
|
||||||
|
int eloop_initialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum hostapd_chan_status {
|
enum hostapd_chan_status {
|
||||||
|
|
Loading…
Reference in a new issue