aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <jouni@codeaurora.org>2020-05-13 14:36:40 (GMT)
committerJouni Malinen <j@w1.fi>2020-05-13 14:39:01 (GMT)
commit95471fc3e88fccdaaabc96227742a619d320c621 (patch)
tree3692d769a2834e86f21157d8cbb2a69b8ba802c7
parent99809c7a44e86918d08aa23d1666c99ccd22693a (diff)
downloadhostap-95471fc3e88fccdaaabc96227742a619d320c621.zip
hostap-95471fc3e88fccdaaabc96227742a619d320c621.tar.gz
hostap-95471fc3e88fccdaaabc96227742a619d320c621.tar.bz2
Handle hostapd_for_each_interface() at the process termination
Clean struct hapd_interfaces pointers and interface count during deinitialization at the end of theh ostapd process termination so that a call to hostapd_for_each_interface() after this does not end up dereferencing freed memory. Such cases do not exist before this commit, but can be added after this, e.g., for DPP needs. Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
-rw-r--r--hostapd/main.c3
-rw-r--r--src/ap/hostapd.c2
2 files changed, 5 insertions, 0 deletions
diff --git a/hostapd/main.c b/hostapd/main.c
index 6a69412..09261d6 100644
--- a/hostapd/main.c
+++ b/hostapd/main.c
@@ -903,8 +903,11 @@ int main(int argc, char *argv[])
!!(interfaces.iface[i]->drv_flags &
WPA_DRIVER_FLAGS_AP_TEARDOWN_SUPPORT);
hostapd_interface_deinit_free(interfaces.iface[i]);
+ interfaces.iface[i] = NULL;
}
os_free(interfaces.iface);
+ interfaces.iface = NULL;
+ interfaces.count = 0;
#ifdef CONFIG_DPP
dpp_global_deinit(interfaces.dpp);
diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index 5515ab3..79ad38c 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -76,6 +76,8 @@ int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
int ret;
for (i = 0; i < interfaces->count; i++) {
+ if (!interfaces->iface[i])
+ continue;
ret = cb(interfaces->iface[i], ctx);
if (ret)
return ret;