Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb usbnet: Don't issue a detach event if we never i...



details:   https://anonhg.NetBSD.org/src/rev/e0b324e2b5c9
branches:  trunk
changeset: 362501:e0b324e2b5c9
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Mar 03 05:49:07 2022 +0000

description:
usbnet: Don't issue a detach event if we never issued an attach one.

diffstat:

 sys/dev/usb/usbnet.c |  13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diffs (34 lines):

diff -r bfd67faef42c -r e0b324e2b5c9 sys/dev/usb/usbnet.c
--- a/sys/dev/usb/usbnet.c      Thu Mar 03 05:49:00 2022 +0000
+++ b/sys/dev/usb/usbnet.c      Thu Mar 03 05:49:07 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbnet.c,v 1.61 2022/03/03 05:49:00 riastradh Exp $    */
+/*     $NetBSD: usbnet.c,v 1.62 2022/03/03 05:49:07 riastradh Exp $    */
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.61 2022/03/03 05:49:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.62 2022/03/03 05:49:07 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -1680,7 +1680,14 @@
 
        pmf_device_deregister(un->un_dev);
 
-       usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, un->un_udev, un->un_dev);
+       /*
+        * Notify userland that we're going away, if we arrived in the
+        * first place.
+        */
+       if (unp->unp_ifp_attached) {
+               usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, un->un_udev,
+                   un->un_dev);
+       }
 
        kmem_free(unp, sizeof(*unp));
        un->un_pri = NULL;



Home | Main Index | Thread Index | Old Index