Index: uspace/drv/bus/usb/xhci/commands.c
===================================================================
--- uspace/drv/bus/usb/xhci/commands.c	(revision 665368c6c3b26ed24d28915e3fc1f040da36e28d)
+++ uspace/drv/bus/usb/xhci/commands.c	(revision f3baab1a8d8cc38434d3d3a99793eb84565ccba8)
@@ -666,4 +666,9 @@
 	int rv = EOK;
 
+	if (fibril_get_id() == hc->event_handler) {
+		usb_log_error("Deadlock detected in waiting for command.");
+		abort();
+	}
+
 	fibril_mutex_lock(&cmd->_header.completed_mtx);
 	while (!cmd->_header.completed) {
Index: uspace/drv/bus/usb/xhci/hc.c
===================================================================
--- uspace/drv/bus/usb/xhci/hc.c	(revision 665368c6c3b26ed24d28915e3fc1f040da36e28d)
+++ uspace/drv/bus/usb/xhci/hc.c	(revision f3baab1a8d8cc38434d3d3a99793eb84565ccba8)
@@ -511,30 +511,11 @@
 {
 	int err;
-	ssize_t size = 16;
-	xhci_trb_t *queue = malloc(sizeof(xhci_trb_t) * size);
-	if (!queue) {
-		usb_log_error("Not enough memory to run the event ring.");
-		return;
-	}
-
-	xhci_trb_t *head = queue;
-
-	while ((err = xhci_event_ring_dequeue(event_ring, head)) != ENOENT) {
-		if (err != EOK) {
-			usb_log_warning("Error while accessing event ring: %s", str_error(err));
-			break;
-		}
-
-		usb_log_debug2("Dequeued trb from event ring: %s", xhci_trb_str_type(TRB_TYPE(*head)));
-		head++;
-
-		/* Expand the array if needed. */
-		if (head - queue >= size) {
-			size *= 2;
-			xhci_trb_t *new_queue = realloc(queue, size);
-			if (new_queue == NULL)
-				break; /* Will process only those TRBs we have memory for. */
-
-			head = new_queue + (head - queue);
+
+	xhci_trb_t trb;
+	hc->event_handler = fibril_get_id();
+
+	while ((err = xhci_event_ring_dequeue(event_ring, &trb)) != ENOENT) {
+		if ((err = hc_handle_event(hc, &trb, intr)) != EOK) {
+			usb_log_error("Failed to handle event: %s", str_error(err));
 		}
 
@@ -543,4 +524,6 @@
 		XHCI_REG_WR(intr, XHCI_INTR_ERDP_HI, UPPER32(erdp));
 	}
+
+	hc->event_handler = 0;
 
 	/* Update the ERDP to make room in the ring. */
@@ -551,15 +534,4 @@
 	XHCI_REG_WR(intr, XHCI_INTR_ERDP_HI, UPPER32(erdp));
 
-	/* Handle all of the collected events if possible. */
-	if (head == queue)
-		usb_log_warning("No events to be handled!");
-
-	for (xhci_trb_t *tail = queue; tail != head; tail++) {
-		if ((err = hc_handle_event(hc, tail, intr)) != EOK) {
-			usb_log_error("Failed to handle event: %s", str_error(err));
-		}
-	}
-
-	free(queue);
 	usb_log_debug2("Event ring run finished.");
 }
Index: uspace/drv/bus/usb/xhci/hc.h
===================================================================
--- uspace/drv/bus/usb/xhci/hc.h	(revision 665368c6c3b26ed24d28915e3fc1f040da36e28d)
+++ uspace/drv/bus/usb/xhci/hc.h	(revision f3baab1a8d8cc38434d3d3a99793eb84565ccba8)
@@ -81,4 +81,7 @@
 	xhci_bus_t bus;
 
+	/* Fibril that is currently hanling events */
+	fid_t event_handler;
+
 	/* Cached capabilities */
 	unsigned max_slots;
