Module Name:    src
Committed By:   jdolecek
Date:           Sun Apr 12 13:55:06 UTC 2020

Modified Files:
        src/sys/arch/xen/xen: if_xennet_xenbus.c

Log Message:
fix locking against myself panic in xennet_stop() on 'ifconfig xennet0 down'

xennet_stop() is called with IFNET already held


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/sys/arch/xen/xen/if_xennet_xenbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/if_xennet_xenbus.c
diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.112 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.113
--- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.112	Sat Apr 11 11:01:12 2020
+++ src/sys/arch/xen/xen/if_xennet_xenbus.c	Sun Apr 12 13:55:06 2020
@@ -1,4 +1,4 @@
-/*      $NetBSD: if_xennet_xenbus.c,v 1.112 2020/04/11 11:01:12 jdolecek Exp $      */
+/*      $NetBSD: if_xennet_xenbus.c,v 1.113 2020/04/12 13:55:06 jdolecek Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -81,7 +81,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.112 2020/04/11 11:01:12 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.113 2020/04/12 13:55:06 jdolecek Exp $");
 
 #include "opt_xen.h"
 #include "opt_nfs_boot.h"
@@ -411,11 +411,13 @@ xennet_xenbus_detach(device_t self, int 
 	DPRINTF(("%s: xennet_xenbus_detach\n", device_xname(self)));
 
 	/* stop interface */
+	IFNET_LOCK(ifp);
 	xennet_stop(ifp, 1);
 	if (sc->sc_ih != NULL) {
 		xen_intr_disestablish(sc->sc_ih);
 		sc->sc_ih = NULL;
 	}
+	IFNET_UNLOCK(ifp);
 
 	/* collect any outstanding TX responses */
 	mutex_enter(&sc->sc_tx_lock);
@@ -1146,9 +1148,9 @@ xennet_stop(struct ifnet *ifp, int disab
 {
 	struct xennet_xenbus_softc *sc = ifp->if_softc;
 
-	IFNET_LOCK(ifp);
+	KASSERT(IFNET_LOCKED(ifp));
+
 	ifp->if_flags &= ~IFF_RUNNING;
-	IFNET_UNLOCK(ifp);
 	hypervisor_mask_event(sc->sc_evtchn);
 }
 

Reply via email to