From c683151962301f5e3ddfb765ea1fc011e415e08c Mon Sep 17 00:00:00 2001 From: mpi Date: Mon, 29 May 2017 06:08:21 +0000 Subject: [PATCH] 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@ --- sys/net/if.c | 13 ++++++------- 1 file 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 -- 2.20.1