nl80211: Clean up if_add() for hostapd use
The allocation of new_bss and its use was separated by a lot of code in this function. This can be cleaned up by moving the allocation next to the use, so that this all can be within a single #ifdef HOSTAPD block. The i802_check_bridge() call was outside type == WPA_IF_AP_BSS case, but in practice, it is only used for WPA_IF_AP_BSS (and if used for something else, this would have resulted in NULL pointer dereference anyway). Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
a288da61b6
commit
f5eb9da304
1 changed files with 16 additions and 21 deletions
|
@ -9117,15 +9117,6 @@ static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type,
|
||||||
struct i802_bss *bss = priv;
|
struct i802_bss *bss = priv;
|
||||||
struct wpa_driver_nl80211_data *drv = bss->drv;
|
struct wpa_driver_nl80211_data *drv = bss->drv;
|
||||||
int ifidx;
|
int ifidx;
|
||||||
#ifdef HOSTAPD
|
|
||||||
struct i802_bss *new_bss = NULL;
|
|
||||||
|
|
||||||
if (type == WPA_IF_AP_BSS) {
|
|
||||||
new_bss = os_zalloc(sizeof(*new_bss));
|
|
||||||
if (new_bss == NULL)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif /* HOSTAPD */
|
|
||||||
|
|
||||||
if (addr)
|
if (addr)
|
||||||
os_memcpy(if_addr, addr, ETH_ALEN);
|
os_memcpy(if_addr, addr, ETH_ALEN);
|
||||||
|
@ -9154,9 +9145,6 @@ static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type,
|
||||||
ifidx = nl80211_create_iface(drv, ifname, nlmode, addr,
|
ifidx = nl80211_create_iface(drv, ifname, nlmode, addr,
|
||||||
0, NULL, NULL);
|
0, NULL, NULL);
|
||||||
if (ifidx < 0) {
|
if (ifidx < 0) {
|
||||||
#ifdef HOSTAPD
|
|
||||||
os_free(new_bss);
|
|
||||||
#endif /* HOSTAPD */
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9201,16 +9189,23 @@ static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type,
|
||||||
#endif /* CONFIG_P2P */
|
#endif /* CONFIG_P2P */
|
||||||
|
|
||||||
#ifdef HOSTAPD
|
#ifdef HOSTAPD
|
||||||
|
if (type == WPA_IF_AP_BSS) {
|
||||||
|
struct i802_bss *new_bss = os_zalloc(sizeof(*new_bss));
|
||||||
|
if (new_bss == NULL) {
|
||||||
|
nl80211_remove_iface(drv, ifidx);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (bridge &&
|
if (bridge &&
|
||||||
i802_check_bridge(drv, new_bss, bridge, ifname) < 0) {
|
i802_check_bridge(drv, new_bss, bridge, ifname) < 0) {
|
||||||
wpa_printf(MSG_ERROR, "nl80211: Failed to add the new "
|
wpa_printf(MSG_ERROR, "nl80211: Failed to add the new "
|
||||||
"interface %s to a bridge %s", ifname, bridge);
|
"interface %s to a bridge %s",
|
||||||
|
ifname, bridge);
|
||||||
nl80211_remove_iface(drv, ifidx);
|
nl80211_remove_iface(drv, ifidx);
|
||||||
os_free(new_bss);
|
os_free(new_bss);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == WPA_IF_AP_BSS) {
|
|
||||||
if (linux_set_iface_flags(drv->global->ioctl_sock, ifname, 1))
|
if (linux_set_iface_flags(drv->global->ioctl_sock, ifname, 1))
|
||||||
{
|
{
|
||||||
nl80211_remove_iface(drv, ifidx);
|
nl80211_remove_iface(drv, ifidx);
|
||||||
|
|
Loading…
Add table
Reference in a new issue