From 05a2398f326a0772ea52ae3f776efd51dcbfc690 Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Thu, 2 Feb 2006 22:11:38 +0000 Subject: In vlan_config() first call vlan_inithash(), then lock mutex, because vlan_inithash() calls malloc(M_WAITOK). --- sys/net/if_vlan.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'sys/net/if_vlan.c') 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); -- cgit v1.2.3