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: Do nothing on if_init/stop if already in...



details:   https://anonhg.NetBSD.org/src/rev/daec57fba641
branches:  trunk
changeset: 362544:daec57fba641
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Mar 03 05:55:10 2022 +0000

description:
usbnet: Do nothing on if_init/stop if already in the target state.

The network stack _shouldn't_ ever call us if so, but I'm not yet
sure it _won't_.

diffstat:

 sys/dev/usb/usbnet.c |  24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)

diffs (52 lines):

diff -r 8448a04aa895 -r daec57fba641 sys/dev/usb/usbnet.c
--- a/sys/dev/usb/usbnet.c      Thu Mar 03 05:55:01 2022 +0000
+++ b/sys/dev/usb/usbnet.c      Thu Mar 03 05:55:10 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbnet.c,v 1.84 2022/03/03 05:54:52 riastradh Exp $    */
+/*     $NetBSD: usbnet.c,v 1.85 2022/03/03 05:55:10 riastradh Exp $    */
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.84 2022/03/03 05:54:52 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.85 2022/03/03 05:55:10 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -1162,6 +1162,16 @@
 
        KASSERTMSG(IFNET_LOCKED(ifp), "%s", ifp->if_xname);
 
+       /*
+        * If we're already stopped, nothing to do.
+        *
+        * XXX This should be an assertion, but it may require some
+        * analysis -- and possibly some tweaking -- of sys/net to
+        * ensure.
+        */
+       if ((ifp->if_flags & IFF_RUNNING) == 0)
+               return;
+
        mutex_enter(&unp->unp_core_lock);
        usbnet_stop(un, ifp, disable);
        mutex_exit(&unp->unp_core_lock);
@@ -1263,6 +1273,16 @@
        if (usbnet_isdying(un))
                return EIO;
 
+       /*
+        * If we're already running, nothing to do.
+        *
+        * XXX This should be an assertion, but it may require some
+        * analysis -- and possibly some tweaking -- of sys/net to
+        * ensure.
+        */
+       if (ifp->if_flags & IFF_RUNNING)
+               return 0;
+
        mutex_enter(&un->un_pri->unp_core_lock);
        error = uno_init(un, ifp);
        mutex_exit(&un->un_pri->unp_core_lock);



Home | Main Index | Thread Index | Old Index