Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Handle detach that happens before attach has fin...



details:   https://anonhg.NetBSD.org/src/rev/03e7309e651c
branches:  trunk
changeset: 482626:03e7309e651c
user:      augustss <augustss%NetBSD.org@localhost>
date:      Thu Feb 17 18:42:21 2000 +0000

description:
Handle detach that happens before attach has finished.  (Reported by mycroft.)

diffstat:

 sys/dev/usb/if_aue.c    |  10 +++++++++-
 sys/dev/usb/if_auereg.h |   3 ++-
 sys/dev/usb/if_cue.c    |  15 ++++++++++++---
 sys/dev/usb/if_cuereg.h |   3 ++-
 sys/dev/usb/if_kue.c    |  18 ++++++++++++++----
 sys/dev/usb/if_kuereg.h |   3 ++-
 6 files changed, 41 insertions(+), 11 deletions(-)

diffs (177 lines):

diff -r 4112b6956af7 -r 03e7309e651c sys/dev/usb/if_aue.c
--- a/sys/dev/usb/if_aue.c      Thu Feb 17 17:37:23 2000 +0000
+++ b/sys/dev/usb/if_aue.c      Thu Feb 17 18:42:21 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_aue.c,v 1.23 2000/02/17 05:41:41 mycroft Exp $      */
+/*     $NetBSD: if_aue.c,v 1.24 2000/02/17 18:42:21 augustss Exp $     */
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
  *     Bill Paul <wpaul%ee.columbia.edu@localhost>.  All rights reserved.
@@ -879,6 +879,7 @@
 
 #endif /* defined(__NetBSD__) || defined(__OpenBSD__) */
 
+       sc->aue_attached = 1;
        splx(s);
 
        usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->aue_udev,
@@ -899,6 +900,12 @@
 
        usb_untimeout(aue_tick, sc, sc->aue_stat_ch);
 
+       if (!sc->aue_attached) {
+               /* Detached before attached finished, so just bail out. */
+               splx(s);
+               return (0);
+       }
+
        if (ifp->if_flags & IFF_RUNNING)
                aue_stop(sc);
 
@@ -924,6 +931,7 @@
                       USBDEVNAME(sc->aue_dev));
 #endif
 
+       sc->aue_attached = 0;
        splx(s);
 
        usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->aue_udev, 
diff -r 4112b6956af7 -r 03e7309e651c sys/dev/usb/if_auereg.h
--- a/sys/dev/usb/if_auereg.h   Thu Feb 17 17:37:23 2000 +0000
+++ b/sys/dev/usb/if_auereg.h   Thu Feb 17 18:42:21 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_auereg.h,v 1.4 2000/02/02 13:19:44 augustss Exp $   */
+/*     $NetBSD: if_auereg.h,v 1.5 2000/02/17 18:42:21 augustss Exp $   */
 /*
  * Copyright (c) 1997, 1998, 1999
  *     Bill Paul <wpaul%ee.columbia.edu@localhost>.  All rights reserved.
@@ -257,6 +257,7 @@
        struct aue_cdata        aue_cdata;
 
        char                    aue_dying;
+       char                    aue_attached;
 };
 
 #define AUE_TIMEOUT            1000
diff -r 4112b6956af7 -r 03e7309e651c sys/dev/usb/if_cue.c
--- a/sys/dev/usb/if_cue.c      Thu Feb 17 17:37:23 2000 +0000
+++ b/sys/dev/usb/if_cue.c      Thu Feb 17 18:42:21 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_cue.c,v 1.6 2000/02/17 05:41:41 mycroft Exp $       */
+/*     $NetBSD: if_cue.c,v 1.7 2000/02/17 18:42:21 augustss Exp $      */
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
  *     Bill Paul <wpaul%ee.columbia.edu@localhost>.  All rights reserved.
@@ -649,6 +649,8 @@
 #endif
 
 #endif /* __NetBSD__ */
+
+       sc->cue_attached = 1;
        splx(s);
 
        usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->cue_udev,
@@ -665,11 +667,17 @@
 
        s = splusb();
 
+       usb_untimeout(cue_tick, sc, sc->cue_stat_ch);
+
+       if (!sc->cue_attached) {
+               /* Detached before attached finished, so just bail out. */
+               splx(s);
+               return (0);
+       }
+
        if (ifp->if_flags & IFF_RUNNING)
                cue_stop(sc);
 
-       usb_untimeout(cue_tick, sc, sc->cue_stat_ch);
-
 #if defined(__NetBSD__)
 #if NRND > 0
        rnd_detach_source(&sc->rnd_source);
@@ -690,6 +698,7 @@
                       USBDEVNAME(sc->cue_dev));
 #endif
 
+       sc->cue_attached = 0;
        splx(s);
 
        usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->cue_udev,
diff -r 4112b6956af7 -r 03e7309e651c sys/dev/usb/if_cuereg.h
--- a/sys/dev/usb/if_cuereg.h   Thu Feb 17 17:37:23 2000 +0000
+++ b/sys/dev/usb/if_cuereg.h   Thu Feb 17 18:42:21 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_cuereg.h,v 1.3 2000/02/02 13:19:45 augustss Exp $   */
+/*     $NetBSD: if_cuereg.h,v 1.4 2000/02/17 18:42:21 augustss Exp $   */
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
  *     Bill Paul <wpaul%ee.columbia.edu@localhost>.  All rights reserved.
@@ -195,4 +195,5 @@
        struct cue_cdata        cue_cdata;
 
        char                    cue_dying;
+       char                    cue_attached;
 };
diff -r 4112b6956af7 -r 03e7309e651c sys/dev/usb/if_kue.c
--- a/sys/dev/usb/if_kue.c      Thu Feb 17 17:37:23 2000 +0000
+++ b/sys/dev/usb/if_kue.c      Thu Feb 17 18:42:21 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_kue.c,v 1.7 2000/02/17 05:41:41 mycroft Exp $       */
+/*     $NetBSD: if_kue.c,v 1.8 2000/02/17 18:42:21 augustss Exp $      */
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
  *     Bill Paul <wpaul%ee.columbia.edu@localhost>.  All rights reserved.
@@ -704,6 +704,7 @@
 #endif
 
 #endif /* __NetBSD__ */
+       sc->kue_attached = 1;
        splx(s);
 
        usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->kue_udev,
@@ -720,6 +721,17 @@
 
        s = splusb();           /* XXX why? */
 
+       if (sc->kue_mcfilters != NULL) {
+               free(sc->kue_mcfilters, M_USBDEV);
+               sc->kue_mcfilters = NULL;
+       }
+
+       if (!sc->kue_attached) {
+               /* Detached before attached finished, so just bail out. */
+               splx(s);
+               return (0);
+       }
+
        if (ifp->if_flags & IFF_RUNNING)
                kue_stop(sc);
 
@@ -743,9 +755,7 @@
                       USBDEVNAME(sc->kue_dev));
 #endif
 
-       if (sc->kue_mcfilters != NULL)
-               free(sc->kue_mcfilters, M_USBDEV);
-
+       sc->kue_attached = 0;
        splx(s);
 
        return (0);
diff -r 4112b6956af7 -r 03e7309e651c sys/dev/usb/if_kuereg.h
--- a/sys/dev/usb/if_kuereg.h   Thu Feb 17 17:37:23 2000 +0000
+++ b/sys/dev/usb/if_kuereg.h   Thu Feb 17 18:42:21 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_kuereg.h,v 1.3 2000/02/02 13:22:07 augustss Exp $   */
+/*     $NetBSD: if_kuereg.h,v 1.4 2000/02/17 18:42:22 augustss Exp $   */
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
  *     Bill Paul <wpaul%ee.columbia.edu@localhost>.  All rights reserved.
@@ -189,4 +189,5 @@
        struct kue_cdata        kue_cdata;
 
        char                    kue_dying;
+       char                    kue_attached;
 };



Home | Main Index | Thread Index | Old Index