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 <michal.kazior@tieto.com>
This commit is contained in:
Michal Kazior 2014-05-28 11:57:09 +02:00 committed by Jouni Malinen
parent 9a17b36e55
commit ea39367c1b

View file

@ -10107,6 +10107,7 @@ static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type,
if (linux_get_ifhwaddr(drv->global->ioctl_sock, ifname, if (linux_get_ifhwaddr(drv->global->ioctl_sock, ifname,
new_addr) < 0) { new_addr) < 0) {
if (added)
nl80211_remove_iface(drv, ifidx); nl80211_remove_iface(drv, ifidx);
return -1; return -1;
} }
@ -10114,11 +10115,13 @@ static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type,
wpa_printf(MSG_DEBUG, "nl80211: Allocate new address " wpa_printf(MSG_DEBUG, "nl80211: Allocate new address "
"for P2P group interface"); "for P2P group interface");
if (nl80211_p2p_interface_addr(drv, new_addr) < 0) { if (nl80211_p2p_interface_addr(drv, new_addr) < 0) {
if (added)
nl80211_remove_iface(drv, ifidx); nl80211_remove_iface(drv, ifidx);
return -1; return -1;
} }
if (linux_set_ifhwaddr(drv->global->ioctl_sock, ifname, if (linux_set_ifhwaddr(drv->global->ioctl_sock, ifname,
new_addr) < 0) { new_addr) < 0) {
if (added)
nl80211_remove_iface(drv, ifidx); nl80211_remove_iface(drv, ifidx);
return -1; return -1;
} }
@ -10148,6 +10151,7 @@ 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)) if (linux_set_iface_flags(drv->global->ioctl_sock, ifname, 1))
{ {
if (added)
nl80211_remove_iface(drv, ifidx); nl80211_remove_iface(drv, ifidx);
os_free(new_bss); os_free(new_bss);
return -1; return -1;