diff options
author | weongyo <weongyo@FreeBSD.org> | 2008-09-10 03:40:51 +0000 |
---|---|---|
committer | weongyo <weongyo@FreeBSD.org> | 2008-09-10 03:40:51 +0000 |
commit | 120d55b5a180fc8f4b45d73c03fe040ad7b58859 (patch) | |
tree | 79a15dc7662e899f158348628b3c06758b7ea8ad | |
parent | 49e85d35c3ebd1dd25c7f931e9f701abb87d8686 (diff) | |
download | FreeBSD-src-120d55b5a180fc8f4b45d73c03fe040ad7b58859.zip FreeBSD-src-120d55b5a180fc8f4b45d73c03fe040ad7b58859.tar.gz |
rename flags and add a ZYD_FLAG_DETACHING flag to indicate we're
detaching that when the USB is pulled out forcibly during the driver is
running background scan, a page fault can be occurred even if we called
usb_rem_task() when detaching. It looks like a kind of races.
-rw-r--r-- | sys/dev/usb/if_zyd.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/if_zydreg.h | 3 |
2 files changed, 9 insertions, 2 deletions
diff --git a/sys/dev/usb/if_zyd.c b/sys/dev/usb/if_zyd.c index 57dce28..cc6c607 100644 --- a/sys/dev/usb/if_zyd.c +++ b/sys/dev/usb/if_zyd.c @@ -268,7 +268,7 @@ zyd_attachhook(struct zyd_softc *sc) return error; } - sc->sc_flags |= ZD1211_FWLOADED; + sc->sc_flags |= ZYD_FLAG_FWLOADED; /* complete the attach process */ return zyd_complete_attach(sc); @@ -451,6 +451,9 @@ zyd_detach(device_t dev) if (!device_is_attached(dev)) return 0; + /* set a flag to indicate we're detaching. */ + sc->sc_flags |= ZYD_FLAG_DETACHING; + /* protect a race when we have listeners related with the driver. */ ifp->if_flags &= ~IFF_UP; @@ -2743,6 +2746,9 @@ zyd_scantask(void *arg) struct ifnet *ifp = sc->sc_ifp; struct ieee80211com *ic = ifp->if_l2com; + if (sc->sc_flags & ZYD_FLAG_DETACHING) + return; + ZYD_LOCK(sc); switch (sc->sc_scan_action) { diff --git a/sys/dev/usb/if_zydreg.h b/sys/dev/usb/if_zydreg.h index 4d9c8fd..bd7d197 100644 --- a/sys/dev/usb/if_zydreg.h +++ b/sys/dev/usb/if_zydreg.h @@ -1198,8 +1198,9 @@ struct zyd_softc { usbd_device_handle sc_udev; usbd_interface_handle sc_iface; int sc_flags; +#define ZYD_FLAG_FWLOADED (1 << 0) +#define ZYD_FLAG_DETACHING (1 << 1) int sc_if_flags; -#define ZD1211_FWLOADED (1 << 0) uint8_t sc_bssid[IEEE80211_ADDR_LEN]; enum ieee80211_state sc_state; |