summaryrefslogtreecommitdiffstats
path: root/sys/net/if_vlan.c
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2006-02-02 22:11:38 +0000
committerglebius <glebius@FreeBSD.org>2006-02-02 22:11:38 +0000
commitd84e5b08c3b14b78f3980d54cb8f5d192b357ed0 (patch)
treeecb5d636c8cfeed5149984716dd365efa0b6218a /sys/net/if_vlan.c
parent724ef57f1f93a99e28b63b961a914ed893651dbc (diff)
downloadFreeBSD-src-d84e5b08c3b14b78f3980d54cb8f5d192b357ed0.zip
FreeBSD-src-d84e5b08c3b14b78f3980d54cb8f5d192b357ed0.tar.gz
In vlan_config() first call vlan_inithash(), then lock mutex, because
vlan_inithash() calls malloc(M_WAITOK).
Diffstat (limited to 'sys/net/if_vlan.c')
-rw-r--r--sys/net/if_vlan.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index de7c2df..c569c1d 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -226,7 +226,6 @@ vlan_freehash(struct ifvlantrunk *trunk)
#ifdef INVARIANTS
int i;
- TRUNK_LOCK_ASSERT(trunk); /* XXX just unhook trunk first? */
KASSERT(trunk->hwidth > 0, ("%s: hwidth not positive", __func__));
for (i = 0; i < (1 << trunk->hwidth); i++)
KASSERT(LIST_EMPTY(&trunk->hash[i]),
@@ -913,15 +912,18 @@ vlan_config(struct ifvlan *ifv, struct ifnet *p, uint16_t tag)
if (p->if_vlantrunk == NULL) {
trunk = malloc(sizeof(struct ifvlantrunk),
M_VLAN, M_WAITOK | M_ZERO);
+#ifndef VLAN_ARRAY
+ vlan_inithash(trunk);
+#endif
VLAN_LOCK();
if (p->if_vlantrunk != NULL) {
/* A race that that is very unlikely to be hit. */
+#ifndef VLAN_ARRAY
+ vlan_freehash(trunk);
+#endif
free(trunk, M_VLAN);
goto exists;
}
-#ifndef VLAN_ARRAY
- vlan_inithash(trunk);
-#endif
TRUNK_LOCK_INIT(trunk);
LIST_INSERT_HEAD(&trunk_list, trunk, trunk_entry);
TRUNK_LOCK(trunk);
OpenPOWER on IntegriCloud