svn commit: r335664 - head/sys/dev/xen/netback

Roger Pau Monné royger at FreeBSD.org
Tue Jun 26 14:07:12 UTC 2018


Author: royger
Date: Tue Jun 26 14:07:11 2018
New Revision: 335664
URL: https://svnweb.freebsd.org/changeset/base/335664

Log:
  xen-netback: fix LOR
  
  lock order reversal: (sleepable after non-sleepable)
   1st 0xfffffe00357ff538 xnb_softc (xen netback softc lock) @ /usr/src/sys/dev/xen/netback/netback.c:1069
   2nd 0xffffffff81fdccb0 intrsrc (intrsrc) @ /usr/src/sys/x86/x86/intr_machdep.c:224
  
  There's no need to hold the lock since the cleaning of the interrupt
  cannot happen in parallel due to the XNBF_IN_SHUTDOWN flag being set.
  Note that the locking in netback needs some improvement or
  clarification.
  
  While there also remove a double newline.
  
  Sponsored by:   Citrix Systems R&D

Modified:
  head/sys/dev/xen/netback/netback.c

Modified: head/sys/dev/xen/netback/netback.c
==============================================================================
--- head/sys/dev/xen/netback/netback.c	Tue Jun 26 14:01:03 2018	(r335663)
+++ head/sys/dev/xen/netback/netback.c	Tue Jun 26 14:07:11 2018	(r335664)
@@ -662,6 +662,7 @@ xnb_disconnect(struct xnb_softc *xnb)
 	mtx_lock(&xnb->rx_lock);
 	mtx_unlock(&xnb->rx_lock);
 
+	mtx_lock(&xnb->sc_lock);
 	/* Free malloc'd softc member variables */
 	if (xnb->bridge != NULL) {
 		free(xnb->bridge, M_XENSTORE);
@@ -689,6 +690,8 @@ xnb_disconnect(struct xnb_softc *xnb)
 	    sizeof(struct xnb_ring_config));
 
 	xnb->flags &= ~XNBF_RING_CONNECTED;
+	mtx_unlock(&xnb->sc_lock);
+
 	return (0);
 }
 
@@ -1066,17 +1069,14 @@ xnb_shutdown(struct xnb_softc *xnb)
 		if_free(xnb->xnb_ifp);
 		xnb->xnb_ifp = NULL;
 	}
-	mtx_lock(&xnb->sc_lock);
 
 	xnb_disconnect(xnb);
 
-	mtx_unlock(&xnb->sc_lock);
 	if (xenbus_get_state(xnb->dev) < XenbusStateClosing)
 		xenbus_set_state(xnb->dev, XenbusStateClosing);
 	mtx_lock(&xnb->sc_lock);
 
 	xnb->flags &= ~XNBF_IN_SHUTDOWN;
-
 
 	/* Indicate to xnb_detach() that is it safe to proceed. */
 	wakeup(xnb);


More information about the svn-src-head mailing list