Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev mii_detach() must come before ifmedia_fini(), otherw...



details:   https://anonhg.NetBSD.org/src/rev/47f5827a38b0
branches:  trunk
changeset: 938815:47f5827a38b0
user:      mrg <mrg%NetBSD.org@localhost>
date:      Tue Sep 15 08:33:40 2020 +0000

description:
mii_detach() must come before ifmedia_fini(), otherwise mii_detach()
will have a NULL mutex and fault.

this appears to have been introduced in february, and may be a problem
in other drivers converted to use ifmedia_fini().  i've only fixed the
two that were faulting for me on sunblade 2000 during reboot.

diffstat:

 sys/dev/ic/gem.c     |  7 ++++---
 sys/dev/pci/if_cas.c |  7 ++++---
 2 files changed, 8 insertions(+), 6 deletions(-)

diffs (68 lines):

diff -r 46ca10d80bf7 -r 47f5827a38b0 sys/dev/ic/gem.c
--- a/sys/dev/ic/gem.c  Tue Sep 15 08:14:31 2020 +0000
+++ b/sys/dev/ic/gem.c  Tue Sep 15 08:33:40 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gem.c,v 1.131 2020/07/15 01:42:27 msaitoh Exp $ */
+/*     $NetBSD: gem.c,v 1.132 2020/09/15 08:33:40 mrg Exp $ */
 
 /*
  *
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.131 2020/07/15 01:42:27 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.132 2020/09/15 08:33:40 mrg Exp $");
 
 #include "opt_inet.h"
 
@@ -175,7 +175,6 @@
                rnd_detach_source(&sc->rnd_source);
                ether_ifdetach(ifp);
                if_detach(ifp);
-               ifmedia_fini(&sc->sc_mii.mii_media);
 
                callout_destroy(&sc->sc_tick_ch);
                callout_destroy(&sc->sc_rx_watchdog);
@@ -184,6 +183,8 @@
        case GEM_ATT_MII:
                sc->sc_att_stage = GEM_ATT_MII;
                mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);
+               ifmedia_fini(&sc->sc_mii.mii_media);
+
                /*FALLTHROUGH*/
        case GEM_ATT_7:
                for (i = 0; i < GEM_NRXDESC; i++) {
diff -r 46ca10d80bf7 -r 47f5827a38b0 sys/dev/pci/if_cas.c
--- a/sys/dev/pci/if_cas.c      Tue Sep 15 08:14:31 2020 +0000
+++ b/sys/dev/pci/if_cas.c      Tue Sep 15 08:33:40 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_cas.c,v 1.43 2020/07/02 09:02:04 msaitoh Exp $      */
+/*     $NetBSD: if_cas.c,v 1.44 2020/09/15 08:33:40 mrg Exp $  */
 /*     $OpenBSD: if_cas.c,v 1.29 2009/11/29 16:19:38 kettenis Exp $    */
 
 /*
@@ -44,7 +44,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_cas.c,v 1.43 2020/07/02 09:02:04 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cas.c,v 1.44 2020/09/15 08:33:40 mrg Exp $");
 
 #ifndef _MODULE
 #include "opt_inet.h"
@@ -765,12 +765,13 @@
 
                ether_ifdetach(ifp);
                if_detach(ifp);
-               ifmedia_fini(&sc->sc_mii.mii_media);
 
                callout_destroy(&sc->sc_tick_ch);
 
                mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);
 
+               ifmedia_fini(&sc->sc_mii.mii_media);
+
                /*FALLTHROUGH*/
        case CAS_ATT_MII:
        case CAS_ATT_7:



Home | Main Index | Thread Index | Old Index