aboutsummaryrefslogtreecommitdiff
path: root/sys/net/if_vlan.c
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2006-02-02 22:11:38 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2006-02-02 22:11:38 +0000
commit05a2398f326a0772ea52ae3f776efd51dcbfc690 (patch)
treeecb5d636c8cfeed5149984716dd365efa0b6218a /sys/net/if_vlan.c
parent44ed341759c0a021df83954932a49a5a4ee13d5e (diff)
downloadsrc-05a2398f326a0772ea52ae3f776efd51dcbfc690.tar.gz
src-05a2398f326a0772ea52ae3f776efd51dcbfc690.zip
In vlan_config() first call vlan_inithash(), then lock mutex, because
vlan_inithash() calls malloc(M_WAITOK).
Notes
Notes: svn path=/head/; revision=155231
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 de7c2df4576c..c569c1d03db0 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);