From: Michal Kazior Date: Wed, 28 May 2014 09:57:09 +0000 (+0200) Subject: nl80211: Fix wpa_driver_nl80211_if_add() failure paths X-Git-Tag: hostap_2_2~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea39367c1bbebad5af646b3dc7932483b63e8151;p=thirdparty%2Fhostap.git nl80211: Fix wpa_driver_nl80211_if_add() failure paths Make sure to not remove interfaces that were not created by hostapd/wpa_supplicant. This was already done on number of the error paths, but not all. Signed-off-by: Michal Kazior --- diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 9f7d0f562..1cb2acd09 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -10107,19 +10107,22 @@ static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type, if (linux_get_ifhwaddr(drv->global->ioctl_sock, ifname, new_addr) < 0) { - nl80211_remove_iface(drv, ifidx); + if (added) + nl80211_remove_iface(drv, ifidx); return -1; } if (nl80211_addr_in_use(drv->global, new_addr)) { wpa_printf(MSG_DEBUG, "nl80211: Allocate new address " "for P2P group interface"); if (nl80211_p2p_interface_addr(drv, new_addr) < 0) { - nl80211_remove_iface(drv, ifidx); + if (added) + nl80211_remove_iface(drv, ifidx); return -1; } if (linux_set_ifhwaddr(drv->global->ioctl_sock, ifname, new_addr) < 0) { - nl80211_remove_iface(drv, ifidx); + if (added) + nl80211_remove_iface(drv, ifidx); return -1; } } @@ -10148,7 +10151,8 @@ static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type, if (linux_set_iface_flags(drv->global->ioctl_sock, ifname, 1)) { - nl80211_remove_iface(drv, ifidx); + if (added) + nl80211_remove_iface(drv, ifidx); os_free(new_bss); return -1; }