diff mbox

[2/4] hostapd: Prevent double interface disabling from segfaulting

Message ID 1401271032-7690-3-git-send-email-michal.kazior@tieto.com
State Accepted
Headers show

Commit Message

Michal Kazior May 28, 2014, 9:57 a.m. UTC
Performing, e.g. `wpa_cli -p /var/run/hostapd raw DISABLE` twice led to
hostapd segmentation fault. Fix this by checking if there is anything to
disable at all before trying.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
---
 src/ap/hostapd.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox

Patch

diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index b7e118c..f5657d6 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -1688,6 +1688,13 @@  int hostapd_disable_iface(struct hostapd_iface *hapd_iface)
 
 	if (hapd_iface == NULL)
 		return -1;
+
+	if (hapd_iface->bss[0]->drv_priv == NULL) {
+		wpa_printf(MSG_ERROR, "Interface %s already disabled",
+			   hapd_iface->conf->bss[0]->iface);
+		return -1;
+	}
+
 	wpa_msg(hapd_iface->bss[0]->msg_ctx, MSG_INFO, AP_EVENT_DISABLED);
 	driver = hapd_iface->bss[0]->driver;
 	drv_priv = hapd_iface->bss[0]->drv_priv;