summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordamien <damien@openbsd.org>2010-05-05 19:47:43 +0000
committerdamien <damien@openbsd.org>2010-05-05 19:47:43 +0000
commit50ef8a5a8cc9fb53297f4cdee2937d736f38fc5c (patch)
tree3b62323af1e412fd74519c8a51205c5760d7cb97
parentsync (diff)
downloadwireguard-openbsd-50ef8a5a8cc9fb53297f4cdee2937d736f38fc5c.tar.xz
wireguard-openbsd-50ef8a5a8cc9fb53297f4cdee2937d736f38fc5c.zip
Prevent a process from entering iwn_ioctl while another process is
tsleep'ing (for example waiting for the firmware to become alive) in iwn_init. I believe this might fix a crash reported by dhill@ This is a temporary fix until I find something better that I will apply to my other drivers that can tsleep in if_init (wpi, run etc...)
-rw-r--r--sys/dev/pci/if_iwn.c11
-rw-r--r--sys/dev/pci/if_iwnvar.h3
2 files changed, 12 insertions, 2 deletions
diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c
index d539fdae379..cc5a31635e1 100644
--- a/sys/dev/pci/if_iwn.c
+++ b/sys/dev/pci/if_iwn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_iwn.c,v 1.93 2010/05/05 19:41:57 damien Exp $ */
+/* $OpenBSD: if_iwn.c,v 1.94 2010/05/05 19:47:43 damien Exp $ */
/*-
* Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -3068,6 +3068,13 @@ iwn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
int s, error = 0;
s = splnet();
+ /*
+ * Prevent processes from entering this function while another
+ * process is tsleep'ing in it.
+ */
+ if (sc->sc_flags & IWN_FLAG_BUSY)
+ return EBUSY;
+ sc->sc_flags |= IWN_FLAG_BUSY;
switch (cmd) {
case SIOCSIFADDR:
@@ -3127,6 +3134,8 @@ iwn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
error = iwn_init(ifp);
}
}
+
+ sc->sc_flags &= ~IWN_FLAG_BUSY;
splx(s);
return error;
}
diff --git a/sys/dev/pci/if_iwnvar.h b/sys/dev/pci/if_iwnvar.h
index 827406c2784..03e7215b5e8 100644
--- a/sys/dev/pci/if_iwnvar.h
+++ b/sys/dev/pci/if_iwnvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_iwnvar.h,v 1.18 2010/04/30 16:06:46 damien Exp $ */
+/* $OpenBSD: if_iwnvar.h,v 1.19 2010/05/05 19:47:43 damien Exp $ */
/*-
* Copyright (c) 2007, 2008
@@ -207,6 +207,7 @@ struct iwn_softc {
#define IWN_FLAG_CALIB_DONE (1 << 2)
#define IWN_FLAG_USE_ICT (1 << 3)
#define IWN_FLAG_INTERNAL_PA (1 << 4)
+#define IWN_FLAG_BUSY (1 << 5)
uint8_t hw_type;
const struct iwn_hal *sc_hal;