--- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -1100,13 +1100,8 @@ int hostapd_setup_interface_complete(str size_t j; u8 *prev_addr; - if (err) { - wpa_printf(MSG_ERROR, "Interface initialization failed"); - hostapd_set_state(iface, HAPD_IFACE_DISABLED); - if (iface->interfaces && iface->interfaces->terminate_on_error) - eloop_terminate(); - return -1; - } + if (err) + goto error; wpa_printf(MSG_DEBUG, "Completing interface initialization"); if (iface->conf->channel) { @@ -1137,7 +1132,7 @@ int hostapd_setup_interface_complete(str hapd->iconf->vht_oper_centr_freq_seg1_idx)) { wpa_printf(MSG_ERROR, "Could not set channel for " "kernel driver"); - return -1; + goto error; } } @@ -1148,7 +1143,7 @@ int hostapd_setup_interface_complete(str hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_WARNING, "Failed to prepare rates table."); - return -1; + goto error; } } @@ -1156,14 +1151,14 @@ int hostapd_setup_interface_complete(str hostapd_set_rts(hapd, hapd->iconf->rts_threshold)) { wpa_printf(MSG_ERROR, "Could not set RTS threshold for " "kernel driver"); - return -1; + goto error; } if (hapd->iconf->fragm_threshold > -1 && hostapd_set_frag(hapd, hapd->iconf->fragm_threshold)) { wpa_printf(MSG_ERROR, "Could not set fragmentation threshold " "for kernel driver"); - return -1; + goto error; } prev_addr = hapd->own_addr; @@ -1173,7 +1168,7 @@ int hostapd_setup_interface_complete(str if (j) os_memcpy(hapd->own_addr, prev_addr, ETH_ALEN); if (hostapd_setup_bss(hapd, j == 0)) - return -1; + goto error; if (hostapd_mac_comp_empty(hapd->conf->bssid) == 0) prev_addr = hapd->own_addr; } @@ -1188,7 +1183,7 @@ int hostapd_setup_interface_complete(str if (hostapd_driver_commit(hapd) < 0) { wpa_printf(MSG_ERROR, "%s: Failed to commit driver " "configuration", __func__); - return -1; + goto error; } /* @@ -1213,6 +1208,13 @@ int hostapd_setup_interface_complete(str iface->interfaces->terminate_on_error--; return 0; + +error: + wpa_printf(MSG_ERROR, "Interface initialization failed"); + hostapd_set_state(iface, HAPD_IFACE_DISABLED); + if (iface->interfaces && iface->interfaces->terminate_on_error) + eloop_terminate(); + return -1; }