summaryrefslogtreecommitdiff
path: root/sys/dev/usb/if_upgt.c
diff options
context:
space:
mode:
authorMarcus Glocker <mglocker@cvs.openbsd.org>2008-01-03 14:47:20 +0000
committerMarcus Glocker <mglocker@cvs.openbsd.org>2008-01-03 14:47:20 +0000
commit06e06a80feca42c2b02c2a4861b1d2a3904eedb6 (patch)
tree34f6a050ffcb3f71936c07625e84f5bf05343326 /sys/dev/usb/if_upgt.c
parent47a48c6860d137865b7a32d44e5d3a6a1b01d6da (diff)
Fix page fault trap which occured when device was detached after a failed
attach attempt.
Diffstat (limited to 'sys/dev/usb/if_upgt.c')
-rw-r--r--sys/dev/usb/if_upgt.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/sys/dev/usb/if_upgt.c b/sys/dev/usb/if_upgt.c
index 88c4ee76f74..cb2f4f2ea9c 100644
--- a/sys/dev/usb/if_upgt.c
+++ b/sys/dev/usb/if_upgt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_upgt.c,v 1.13 2008/01/02 10:07:26 mglocker Exp $ */
+/* $OpenBSD: if_upgt.c,v 1.14 2008/01/03 14:47:19 mglocker Exp $ */
/*
* Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org>
@@ -69,6 +69,7 @@
* Sebastien Bourdeauducq <lekernel@prism54.org>.
*/
+#define UPGT_DEBUG
#ifdef UPGT_DEBUG
int upgt_debug = 2;
#define DPRINTF(l, x...) do { if ((l) <= upgt_debug) printf(x); } while (0)
@@ -438,17 +439,8 @@ upgt_detach(struct device *self, int flags)
struct ifnet *ifp = &sc->sc_ic.ic_if;
int s;
- if (!(sc->sc_flags & UPGT_DEVICE_ATTACHED))
- /* device was not properly attached */
- return (0);
-
s = splusb();
- /* remove tasks and timeouts */
- usb_rem_task(sc->sc_udev, &sc->sc_task_newstate);
- usb_rem_task(sc->sc_udev, &sc->sc_task_tx);
- timeout_del(&sc->scan_to);
-
/* abort and close TX / RX pipes */
if (sc->sc_tx_pipeh != NULL) {
usbd_abort_pipe(sc->sc_tx_pipeh);
@@ -459,6 +451,11 @@ upgt_detach(struct device *self, int flags)
usbd_close_pipe(sc->sc_rx_pipeh);
}
+ /* remove tasks and timeouts */
+ usb_rem_task(sc->sc_udev, &sc->sc_task_newstate);
+ usb_rem_task(sc->sc_udev, &sc->sc_task_tx);
+ timeout_del(&sc->scan_to);
+
/* free xfers */
upgt_free_tx(sc);
upgt_free_rx(sc);
@@ -467,9 +464,11 @@ upgt_detach(struct device *self, int flags)
/* free firmware */
upgt_fw_free(sc);
- /* detach interface */
- ieee80211_ifdetach(ifp);
- if_detach(ifp);
+ if (sc->sc_flags & UPGT_DEVICE_ATTACHED) {
+ /* detach interface */
+ ieee80211_ifdetach(ifp);
+ if_detach(ifp);
+ }
splx(s);