Index: uspace/drv/bus/usb/xhci/hc.c
===================================================================
--- uspace/drv/bus/usb/xhci/hc.c	(revision 6fa91e4c93068032f387570765baf8ad5ae309d3)
+++ uspace/drv/bus/usb/xhci/hc.c	(revision 9ee13a79bcd6db7099518b99c4303cd335870155)
@@ -367,12 +367,4 @@
 	xhci_free_command(cmd);
 
-	for (int i = 0; i < 10; ++i) {
-		xhci_cmd_t *cmd2 = xhci_alloc_command();
-		xhci_send_enable_slot_command(hc, cmd2);
-		xhci_wait_for_command(cmd2, 1000000);
-		usb_log_error("Enabled slot ID: %u.", cmd2->slot_id);
-		xhci_free_command(cmd2);
-	}
-
 	return EOK;
 }
Index: uspace/drv/bus/usb/xhci/rh.c
===================================================================
--- uspace/drv/bus/usb/xhci/rh.c	(revision 6fa91e4c93068032f387570765baf8ad5ae309d3)
+++ uspace/drv/bus/usb/xhci/rh.c	(revision 9ee13a79bcd6db7099518b99c4303cd335870155)
@@ -82,20 +82,19 @@
 
 	// TODO: where do we save this? the ring should be associated with device structure somewhere
-	xhci_trb_ring_t* ep_ring = malloc32(sizeof(xhci_trb_ring_t));
+	xhci_trb_ring_t *ep_ring = malloc32(sizeof(xhci_trb_ring_t));
 	if (!ep_ring) {
 		err = ENOMEM;
-		goto err_ring;    
-	}
+		goto err_ictx;
+	}
+
 	err = xhci_trb_ring_init(ep_ring, hc);
-	if (err) {
-		xhci_trb_ring_fini(ep_ring);
+	if (err)
 		goto err_ring;
-	}
-
-	xhci_port_regs_t* regs = &hc->op_regs->portrs[port - 1];
+
+	xhci_port_regs_t *regs = &hc->op_regs->portrs[port - 1];
 	uint8_t port_speed_id = XHCI_REG_RD(regs, XHCI_PORT_PS);
 
 	XHCI_EP_TYPE_SET(ictx->endpoint_ctx[0], 4);
-	XHCI_EP_MAX_PACKET_SIZE_SET(ictx->endpoint_ctx[0], 
+	XHCI_EP_MAX_PACKET_SIZE_SET(ictx->endpoint_ctx[0],
 	    hc->speeds[port_speed_id].tx_bps);
 	XHCI_EP_MAX_BURST_SIZE_SET(ictx->endpoint_ctx[0], 0);
@@ -106,33 +105,42 @@
 	XHCI_EP_MULT_SET(ictx->endpoint_ctx[0], 0);
 	XHCI_EP_ERROR_COUNT_SET(ictx->endpoint_ctx[0], 3);
-	
+
 	// TODO: What's the alignment?
 	xhci_device_ctx_t *dctx = malloc32(sizeof(xhci_device_ctx_t));
 	if (!dctx) {
 		err = ENOMEM;
-		goto err_ctx;
+		goto err_ring;
 	}
 	memset(dctx, 0, sizeof(xhci_device_ctx_t));
-	
+
 	hc->dcbaa[slot_id] = addr_to_phys(dctx);
 	hc->dcbaa_virt[slot_id] = dctx;
-	
+
 	cmd = xhci_alloc_command();
 	cmd->ictx = ictx;
 	xhci_send_address_device_command(hc, cmd);
 	if ((err = xhci_wait_for_command(cmd, 100000)) != EOK)
-		goto err_ctx;
-
-	return EOK;
-
-err_ctx:
+		goto err_dctx;
+
+	return EOK;
+
+err_dctx:
+	if (dctx) {
+		free32(dctx);
+		hc->dcbaa[slot_id] = 0;
+		hc->dcbaa_virt[slot_id] = NULL;
+	}
+err_ring:
+	if (ep_ring) {
+		xhci_trb_ring_fini(ep_ring);
+		free32(ep_ring);
+	}
+err_ictx:
 	if (ictx) {
 		/* Avoid double free. */
 		if (cmd && cmd->ictx && cmd->ictx == ictx)
 			cmd->ictx = NULL;
-	}
-err_ring:
-	if (ep_ring) 
-		free32(ep_ring);
+		free32(ictx);
+	}
 err_command:
 	if (cmd)
