[PATCH] hostapd: Clean interface_added flag

Marek Kwaczynski marek.kwaczynski
Fri Dec 13 01:32:36 PST 2013

If more BSS networks are added in config file than are
supported by the driver, segmantation fault can appear.
For this case clean interface_added flag is needed when
adding new BSS failed.

Signed-hostap: Marek Kwaczynski <marek.kwaczynski at tieto.com>

Without this fix I saw segmantation fault or
"wlan0: Could not connect to kernel driver" in hostapd
when I added more BSS networks in config file than are
supported by the driver. For example when I created the
following BSSs in config file:
1) wlan0
2) wlan0-1
3) wlan0-2
4) wlan0-3

and the last one couldn't be added because it wasn't supported
by the driver, I received the following debug print:

nl80211: Adding interface wlan0-3 into bridge br-lan
Could not set interface wlan0-3 flags (UP): Device or resource

After that when I killed hostapd, it tried to remove wlan0-3
and delete global bss pointer - wlan0

 src/ap/hostapd.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index 6fe2956..a436c2a 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -667,6 +667,7 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
 				   NULL, first == -1)) {
 			wpa_printf(MSG_ERROR, "Failed to add BSS (BSSID="
 				   MACSTR ")", MAC2STR(hapd->own_addr));
+			hapd->interface_added = 0;
 			return -1;

More information about the Hostap mailing list