Module Name:    src
Committed By:   nakayama
Date:           Thu Feb 26 16:07:11 UTC 2015

Modified Files:
        src/sys/dev/ic: tulip.c

Log Message:
Stop the interface before detaching to avoid the race between
tlp_detach() and tlp_intr().

While there, add missing callout_destroy()s.


To generate a diff of this commit:
cvs rdiff -u -r1.184 -r1.185 src/sys/dev/ic/tulip.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/dev/ic/tulip.c
diff -u src/sys/dev/ic/tulip.c:1.184 src/sys/dev/ic/tulip.c:1.185
--- src/sys/dev/ic/tulip.c:1.184	Sun Aug 10 16:44:35 2014
+++ src/sys/dev/ic/tulip.c	Thu Feb 26 16:07:10 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: tulip.c,v 1.184 2014/08/10 16:44:35 tls Exp $	*/
+/*	$NetBSD: tulip.c,v 1.185 2015/02/26 16:07:10 nakayama Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.184 2014/08/10 16:44:35 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.185 2015/02/26 16:07:10 nakayama Exp $");
 
 
 #include <sys/param.h>
@@ -592,7 +592,7 @@ tlp_detach(struct tulip_softc *sc)
 	struct tulip_rxsoft *rxs;
 	struct tulip_txsoft *txs;
 	device_t self = sc->sc_dev;
-	int i;
+	int i, s;
 
 	/*
 	 * Succeed now if there isn't any work to do.
@@ -600,9 +600,14 @@ tlp_detach(struct tulip_softc *sc)
 	if ((sc->sc_flags & TULIPF_ATTACHED) == 0)
 		return (0);
 
-	/* Unhook our tick handler. */
-	if (sc->sc_tick)
-		callout_stop(&sc->sc_tick_callout);
+	s = splnet();
+	/* Stop the interface. Callouts are stopped in it. */
+	tlp_stop(ifp, 1);
+	splx(s);
+
+	/* Destroy our callouts. */
+	callout_destroy(&sc->sc_nway_callout);
+	callout_destroy(&sc->sc_tick_callout);
 
 	if (sc->sc_flags & TULIPF_HAS_MII) {
 		/* Detach all PHYs */

Reply via email to