diff options
author | 2017-05-29 06:08:21 +0000 | |
---|---|---|
committer | 2017-05-29 06:08:21 +0000 | |
commit | c683151962301f5e3ddfb765ea1fc011e415e08c (patch) | |
tree | 5305faf5b6a4572b18c6b6ff0a4a1331c5a2976a | |
parent | copyin32 implementation from miod@ (diff) | |
download | wireguard-openbsd-c683151962301f5e3ddfb765ea1fc011e415e08c.tar.xz wireguard-openbsd-c683151962301f5e3ddfb765ea1fc011e415e08c.zip |
Do not try to grab the NET_LOCK() while holding an ifp reference.
Fix a deadlock with a thread trying to detach the corresponding interface.
ok sashan@, bluhm@
-rw-r--r-- | sys/net/if.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 8532743929e..d519ddcfeba 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.499 2017/05/28 12:51:33 yasuoka Exp $ */ +/* $OpenBSD: if.c,v 1.500 2017/05/29 06:08:21 mpi Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -1559,15 +1559,14 @@ if_linkstate_task(void *xifidx) struct ifnet *ifp; int s; - ifp = if_get(ifidx); - if (ifp == NULL) - return; - NET_LOCK(s); - if_linkstate(ifp); - NET_UNLOCK(s); + ifp = if_get(ifidx); + if (ifp != NULL) + if_linkstate(ifp); if_put(ifp); + + NET_UNLOCK(s); } void |