diff options
| author | riastradh <riastradh@NetBSD.org> | 2022-03-03 05:49:44 +0000 |
|---|---|---|
| committer | riastradh <riastradh@NetBSD.org> | 2022-03-03 05:49:44 +0000 |
| commit | 4ffe6ea41cf0ef43a0181ecdb2591accb1344824 (patch) | |
| tree | 48dcb97046901c1563424e5d579b0d6557b09fc8 /sys/dev | |
| parent | 458bf894dec31cf7d7c2fdec30b368984623921b (diff) | |
usbnet: Avoid IFNET_LOCK on detach if we never attached the ifp.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/usb/usbnet.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/sys/dev/usb/usbnet.c b/sys/dev/usb/usbnet.c index 0b66295f48a..7f676409a70 100644 --- a/sys/dev/usb/usbnet.c +++ b/sys/dev/usb/usbnet.c @@ -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 @@ usbnet_detach(device_t self, int flags) /* * 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 |
