diff options
| author | riastradh <riastradh@NetBSD.org> | 2022-03-03 05:55:10 +0000 |
|---|---|---|
| committer | riastradh <riastradh@NetBSD.org> | 2022-03-03 05:55:10 +0000 |
| commit | 93dbdbd40f65e621ccc8201427d0178c5ed6f27f (patch) | |
| tree | e35a4944b3f532d02517ea91f447ea309f59a75a /sys/dev | |
| parent | a5bc9be03ed762275ec00f70e1c942fa3395ae39 (diff) | |
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 (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/usb/usbnet.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/sys/dev/usb/usbnet.c b/sys/dev/usb/usbnet.c index 1da5f2d6cbb..b10cd8baf9b 100644 --- a/sys/dev/usb/usbnet.c +++ b/sys/dev/usb/usbnet.c @@ -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 @@ usbnet_if_stop(struct ifnet *ifp, int disable) 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 @@ usbnet_if_init(struct ifnet *ifp) 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); |
