Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Feb 2018 08:44:51 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r329904 - head/sys/dev/usb/net
Message-ID:  <201802240844.w1O8ipGJ021887@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Sat Feb 24 08:44:51 2018
New Revision: 329904
URL: https://svnweb.freebsd.org/changeset/base/329904

Log:
  Fix race when detach is called right after attach in if_axge, that the
  network device pointer might be NULL. Wait for any pending tasks to
  complete before calling axge_stop().
  
  MFC after:	1 week
  Sponsored by:	Mellanox Technologies

Modified:
  head/sys/dev/usb/net/if_axge.c

Modified: head/sys/dev/usb/net/if_axge.c
==============================================================================
--- head/sys/dev/usb/net/if_axge.c	Sat Feb 24 04:02:06 2018	(r329903)
+++ head/sys/dev/usb/net/if_axge.c	Sat Feb 24 08:44:51 2018	(r329904)
@@ -587,6 +587,10 @@ axge_detach(device_t dev)
 	sc = device_get_softc(dev);
 	ue = &sc->sc_ue;
 	if (device_is_attached(dev)) {
+
+		/* wait for any post attach or other command to complete */
+		usb_proc_drain(&ue->ue_tq);
+
 		AXGE_LOCK(sc);
 		/*
 		 * XXX
@@ -878,7 +882,8 @@ axge_stop(struct usb_ether *ue)
 	val &= ~MSR_RE;
 	axge_write_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_MSR, val);
 
-	ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
+	if (ifp != NULL)
+		ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
 	sc->sc_flags &= ~AXGE_FLAG_LINK;
 
 	/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802240844.w1O8ipGJ021887>