struct comedi_async *async = s->async;
        unsigned runflags = 0;
        unsigned runflags_mask = 0;
+       unsigned int events = async->events;
 
+       async->events = 0;
        if (!comedi_is_subdevice_running(s))
                return;
 
-       if (async->events & COMEDI_CB_CANCEL_MASK)
+       if (events & COMEDI_CB_CANCEL_MASK)
                runflags_mask |= COMEDI_SRF_RUNNING;
 
        /*
         * Remember if an error event has occurred, so an error
         * can be returned the next time the user does a read().
         */
-       if (async->events & COMEDI_CB_ERROR_MASK) {
+       if (events & COMEDI_CB_ERROR_MASK) {
                runflags_mask |= COMEDI_SRF_ERROR;
                runflags |= COMEDI_SRF_ERROR;
        }
                comedi_update_subdevice_runflags(s, runflags_mask, runflags);
        }
 
-       if (async->cb_mask & async->events) {
+       if (async->cb_mask & events) {
                wake_up_interruptible(&async->wait_head);
                if (s->subdev_flags & SDF_CMD_READ)
                        kill_fasync(&dev->async_queue, SIGIO, POLL_IN);
                if (s->subdev_flags & SDF_CMD_WRITE)
                        kill_fasync(&dev->async_queue, SIGIO, POLL_OUT);
        }
-       async->events = 0;
 }
 EXPORT_SYMBOL_GPL(comedi_event);