union xhci_trb *event;
        u32 trb_type;
 
-       /* Event ring hasn't been allocated yet. */
-       if (!ir || !ir->event_ring || !ir->event_ring->dequeue) {
-               xhci_err(xhci, "ERROR interrupter not ready\n");
-               return -ENOMEM;
-       }
-
        event = ir->event_ring->dequeue;
 
        if (!unhandled_event_trb(ir->event_ring))
 
        xhci_clear_interrupt_pending(xhci, ir);
 
+       /* Event ring hasn't been allocated yet. */
+       if (!ir->event_ring || !ir->event_ring->dequeue) {
+               xhci_err(xhci, "ERROR interrupter event ring not ready\n");
+               return -ENOMEM;
+       }
+
        if (xhci->xhc_state & XHCI_STATE_DYING ||
            xhci->xhc_state & XHCI_STATE_HALTED) {
                xhci_dbg(xhci, "xHCI dying, ignoring interrupt. Shouldn't IRQs be disabled?\n");