The rsu(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_rsu.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/if_rsu.c,v
retrieving revision 1.27
diff -u -p -r1.27 if_rsu.c
--- if_rsu.c    12 Jun 2015 15:47:31 -0000      1.27
+++ if_rsu.c    11 Jul 2015 08:22:46 -0000
@@ -487,16 +487,20 @@ rsu_task(void *arg)
        struct rsu_softc *sc = arg;
        struct rsu_host_cmd_ring *ring = &sc->cmdq;
        struct rsu_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) % RSU_HOST_CMD_RING_COUNT;
        }
@@ -512,6 +516,11 @@ rsu_do_async(struct rsu_softc *sc,
        int s;
 
        s = splusb();
+       if (ring->queued == RSU_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));
@@ -2310,6 +2319,10 @@ rsu_stop(struct ifnet *ifp)
        ic->ic_scan_lock = IEEE80211_SCAN_UNLOCKED;
 
        s = splusb();
+
+       /* Abort rsu_task thread. */
+       sc->cmdq.generation++;
+
        ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
        /* Wait for all async commands to complete. */
        rsu_wait_async(sc);
Index: if_rsureg.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/if_rsureg.h,v
retrieving revision 1.3
diff -u -p -r1.3 if_rsureg.h
--- if_rsureg.h 15 Apr 2013 09:23:01 -0000      1.3
+++ if_rsureg.h 11 Jul 2015 08:21:20 -0000
@@ -711,6 +711,7 @@ struct rsu_host_cmd_ring {
        int                     cur;
        int                     next;
        int                     queued;
+       int                     generation;
 };
 
 struct rsu_softc {

Reply via email to