The urtwn(4) USB driver uses the same broken pattern as run(4).
See http://marc.info/?l=openbsd-tech&m=143660130627359&w=2
Single-band driver, so not actually affected.
Fix anyway for posterity.
Index: if_urtwn.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/if_urtwn.c,v
retrieving revision 1.48
diff -u -p -r1.48 if_urtwn.c
--- if_urtwn.c 12 Jun 2015 15:47:31 -0000 1.48
+++ if_urtwn.c 11 Jul 2015 08:45:30 -0000
@@ -617,16 +617,20 @@ urtwn_task(void *arg)
struct urtwn_softc *sc = arg;
struct urtwn_host_cmd_ring *ring = &sc->cmdq;
struct urtwn_host_cmd *cmd;
- int s;
+ int s, generation;
/* Process host commands. */
s = splusb();
+ generation = ring->generation;
while (ring->next != ring->cur) {
cmd = &ring->cmd[ring->next];
splx(s);
/* Invoke callback. */
cmd->cb(sc, cmd->data);
s = splusb();
+ /* Abort this task if interface was stopped meanwhile. */
+ if (generation != ring->generation)
+ break;
ring->queued--;
ring->next = (ring->next + 1) % URTWN_HOST_CMD_RING_COUNT;
}
@@ -642,6 +646,11 @@ urtwn_do_async(struct urtwn_softc *sc,
int s;
s = splusb();
+ if (ring->queued == URTWN_HOST_CMD_RING_COUNT) {
+ printf("%s: host command ring overflow\n", sc->sc_dev.dv_xname);
+ splx(s);
+ return;
+ }
cmd = &ring->cmd[ring->cur];
cmd->cb = cb;
KASSERT(len <= sizeof(cmd->data));
@@ -3735,6 +3744,10 @@ urtwn_stop(struct ifnet *ifp)
ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
s = splusb();
+
+ /* Abort urtwn_task thread. */
+ sc->cmdq.generation++;
+
ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
/* Wait for all async commands to complete. */
urtwn_wait_async(sc);
Index: if_urtwnreg.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/if_urtwnreg.h,v
retrieving revision 1.7
diff -u -p -r1.7 if_urtwnreg.h
--- if_urtwnreg.h 12 May 2015 11:19:35 -0000 1.7
+++ if_urtwnreg.h 11 Jul 2015 08:43:32 -0000
@@ -1137,6 +1137,7 @@ struct urtwn_host_cmd_ring {
int cur;
int next;
int queued;
+ int generation;
};
struct urtwn_softc {