summaryrefslogtreecommitdiff
path: root/sys/dev/ic/pgt.c
diff options
context:
space:
mode:
authorMarcus Glocker <mglocker@cvs.openbsd.org>2006-10-13 22:35:50 +0000
committerMarcus Glocker <mglocker@cvs.openbsd.org>2006-10-13 22:35:50 +0000
commitfbeba11ffeafc545d586c1392f9557479dba54ea (patch)
treeca5ae3e013cd0577a50c03966cce092be489cd07 /sys/dev/ic/pgt.c
parent06c7902ac6bc4231f18bc26a11deca993527784a (diff)
Fix kernel page fault when the device gets detached after the firmware
failed to load. Spotted by bernd@, aaron@ ok claudio@
Diffstat (limited to 'sys/dev/ic/pgt.c')
-rw-r--r--sys/dev/ic/pgt.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/sys/dev/ic/pgt.c b/sys/dev/ic/pgt.c
index 2d84b6e59ac..ed98c03d8dc 100644
--- a/sys/dev/ic/pgt.c
+++ b/sys/dev/ic/pgt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pgt.c,v 1.36 2006/10/11 19:42:28 damien Exp $ */
+/* $OpenBSD: pgt.c,v 1.37 2006/10/13 22:35:49 mglocker Exp $ */
/*
* Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
@@ -625,14 +625,14 @@ pgt_attach(void *xsc)
int
pgt_detach(struct pgt_softc *sc)
{
+ if (sc->sc_flags & SC_NEEDS_FIRMWARE || sc->sc_flags & SC_UNINITIALIZED)
+ /* device was not initialized correctly, so leave early */
+ goto out;
+
/* stop card */
pgt_stop(sc, SC_DYING);
pgt_reboot(sc);
- /* disable card if possible */
- if (sc->sc_disable != NULL)
- (*sc->sc_disable)(sc);
-
/*
* Disable shutdown and power hooks
*/
@@ -644,6 +644,11 @@ pgt_detach(struct pgt_softc *sc)
ieee80211_ifdetach(&sc->sc_ic.ic_if);
if_detach(&sc->sc_ic.ic_if);
+out:
+ /* disable card if possible */
+ if (sc->sc_disable != NULL)
+ (*sc->sc_disable)(sc);
+
pgt_dma_free(sc);
return (0);