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>
This commit is contained in:
parent
99809c7a44
commit
95471fc3e8
2 changed files with 5 additions and 0 deletions
|
@ -903,8 +903,11 @@ int main(int argc, char *argv[])
|
||||||
!!(interfaces.iface[i]->drv_flags &
|
!!(interfaces.iface[i]->drv_flags &
|
||||||
WPA_DRIVER_FLAGS_AP_TEARDOWN_SUPPORT);
|
WPA_DRIVER_FLAGS_AP_TEARDOWN_SUPPORT);
|
||||||
hostapd_interface_deinit_free(interfaces.iface[i]);
|
hostapd_interface_deinit_free(interfaces.iface[i]);
|
||||||
|
interfaces.iface[i] = NULL;
|
||||||
}
|
}
|
||||||
os_free(interfaces.iface);
|
os_free(interfaces.iface);
|
||||||
|
interfaces.iface = NULL;
|
||||||
|
interfaces.count = 0;
|
||||||
|
|
||||||
#ifdef CONFIG_DPP
|
#ifdef CONFIG_DPP
|
||||||
dpp_global_deinit(interfaces.dpp);
|
dpp_global_deinit(interfaces.dpp);
|
||||||
|
|
|
@ -76,6 +76,8 @@ int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
for (i = 0; i < interfaces->count; i++) {
|
for (i = 0; i < interfaces->count; i++) {
|
||||||
|
if (!interfaces->iface[i])
|
||||||
|
continue;
|
||||||
ret = cb(interfaces->iface[i], ctx);
|
ret = cb(interfaces->iface[i], ctx);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in a new issue