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: Avoid IFNET_LOCK on detach if we never a...



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

description:
usbnet: Avoid IFNET_LOCK on detach if we never attached the ifp.

diffstat:

 sys/dev/usb/usbnet.c |  17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diffs (40 lines):

diff -r d1bc3937ca3f -r 440404044dfc sys/dev/usb/usbnet.c
--- a/sys/dev/usb/usbnet.c      Thu Mar 03 05:49:37 2022 +0000
+++ b/sys/dev/usb/usbnet.c      Thu Mar 03 05:49:44 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbnet.c,v 1.66 2022/03/03 05:49:37 riastradh Exp $    */
+/*     $NetBSD: usbnet.c,v 1.67 2022/03/03 05:49:44 riastradh Exp $    */
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.66 2022/03/03 05:49:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.67 2022/03/03 05:49:44 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -1578,12 +1578,17 @@
        /*
         * If we're still running on the network, stop and wait for all
         * asynchronous activity to finish.
+        *
+        * If usbnet_attach_ifp never ran, IFNET_LOCK won't work, but
+        * no activity is possible, so just skip this part.
         */
-       IFNET_LOCK(ifp);
-       if (ifp->if_flags & IFF_RUNNING) {
-               usbnet_if_stop(ifp, 1);
+       if (unp->unp_ifp_attached) {
+               IFNET_LOCK(ifp);
+               if (ifp->if_flags & IFF_RUNNING) {
+                       usbnet_if_stop(ifp, 1);
+               }
+               IFNET_UNLOCK(ifp);
        }
-       IFNET_UNLOCK(ifp);
 
        /*
         * The callout and tick task can't be scheduled anew at this



Home | Main Index | Thread Index | Old Index