hostapd: Simplify vlan_add_dynamic error paths

Preparation for upcoming changes.
No functional changes.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
This commit is contained in:
Helmut Schaa 2014-03-17 14:16:24 +01:00 committed by Jouni Malinen
parent 99805a0ea1
commit 66bc6830d5

View file

@ -891,7 +891,7 @@ struct hostapd_vlan * vlan_add_dynamic(struct hostapd_data *hapd,
struct hostapd_vlan *vlan, struct hostapd_vlan *vlan,
int vlan_id) int vlan_id)
{ {
struct hostapd_vlan *n; struct hostapd_vlan *n = NULL;
char *ifname, *pos; char *ifname, *pos;
if (vlan == NULL || vlan_id <= 0 || vlan_id > MAX_VLAN_ID || if (vlan == NULL || vlan_id <= 0 || vlan_id > MAX_VLAN_ID ||
@ -904,28 +904,24 @@ struct hostapd_vlan * vlan_add_dynamic(struct hostapd_data *hapd,
if (ifname == NULL) if (ifname == NULL)
return NULL; return NULL;
pos = os_strchr(ifname, '#'); pos = os_strchr(ifname, '#');
if (pos == NULL) { if (pos == NULL)
os_free(ifname); goto free_ifname;
return NULL;
}
*pos++ = '\0'; *pos++ = '\0';
n = os_zalloc(sizeof(*n)); n = os_zalloc(sizeof(*n));
if (n == NULL) { if (n == NULL)
os_free(ifname); goto free_ifname;
return NULL;
}
n->vlan_id = vlan_id; n->vlan_id = vlan_id;
n->dynamic_vlan = 1; n->dynamic_vlan = 1;
os_snprintf(n->ifname, sizeof(n->ifname), "%s%d%s", ifname, vlan_id, os_snprintf(n->ifname, sizeof(n->ifname), "%s%d%s", ifname, vlan_id,
pos); pos);
os_free(ifname);
if (hostapd_vlan_if_add(hapd, n->ifname)) { if (hostapd_vlan_if_add(hapd, n->ifname)) {
os_free(n); os_free(n);
return NULL; n = NULL;
goto free_ifname;
} }
n->next = hapd->conf->vlan; n->next = hapd->conf->vlan;
@ -935,6 +931,8 @@ struct hostapd_vlan * vlan_add_dynamic(struct hostapd_data *hapd,
ifconfig_up(n->ifname); ifconfig_up(n->ifname);
#endif /* CONFIG_FULL_DYNAMIC_VLAN */ #endif /* CONFIG_FULL_DYNAMIC_VLAN */
free_ifname:
os_free(ifname);
return n; return n;
} }