Index: uspace/drv/uhci-rhd/port.c
===================================================================
--- uspace/drv/uhci-rhd/port.c	(revision e247d83f26c1f9fc072e178ccded2ab08a6893c0)
+++ uspace/drv/uhci-rhd/port.c	(revision af6136de008f4fcb3a666bcb1be8d411397d47fe)
@@ -36,5 +36,4 @@
 #include <errno.h>
 #include <str_error.h>
-#include <time.h>
 #include <async.h>
 
@@ -82,5 +81,5 @@
  * @param[in] number Port number.
  * @param[in] usec Polling interval.
- * @param[in] rh Pointer to ddf instance fo the root hub driver.
+ * @param[in] rh Pointer to ddf instance of the root hub driver.
  * @return Error code.
  *
@@ -91,9 +90,11 @@
 {
 	assert(port);
-	asprintf(&port->id_string, "Port (%p - %u)", port, number);
-	if (port->id_string == NULL) {
+	char *id_string;
+	asprintf(&id_string, "Port (%p - %u)", port, number);
+	if (id_string == NULL) {
 		return ENOMEM;
 	}
 
+	port->id_string = id_string;
 	port->address = address;
 	port->number = number;
@@ -105,5 +106,7 @@
 	    usb_hc_connection_initialize_from_device(&port->hc_connection, rh);
 	if (ret != EOK) {
-		usb_log_error("Failed to initialize connection to HC.");
+		usb_log_error("%s: failed to initialize connection to HC.",
+		    port->id_string);
+		free(id_string);
 		return ret;
 	}
@@ -113,4 +116,5 @@
 		usb_log_error("%s: failed to create polling fibril.",
 		    port->id_string);
+		free(id_string);
 		return ENOMEM;
 	}
@@ -132,5 +136,5 @@
 	assert(port);
 	free(port->id_string);
-	/* TODO: Kill fibril here */
+	// TODO: Kill fibril here
 	return;
 }
@@ -150,5 +154,6 @@
 
 		/* Read register value */
-		port_status_t port_status = uhci_port_read_status(instance);
+		const port_status_t port_status =
+		    uhci_port_read_status(instance);
 
 		/* Print the value if it's interesting */
@@ -161,12 +166,4 @@
 		usb_log_debug("%s: Connected change detected: %x.\n",
 		    instance->id_string, port_status);
-
-		int rc =
-		    usb_hc_connection_open(&instance->hc_connection);
-		if (rc != EOK) {
-			usb_log_error("%s: Failed to connect to HC.",
-			    instance->id_string);
-			continue;
-		}
 
 		/* Remove any old device */
@@ -175,4 +172,12 @@
 			    instance->id_string);
 			uhci_port_remove_device(instance);
+		}
+
+		int ret =
+		    usb_hc_connection_open(&instance->hc_connection);
+		if (ret != EOK) {
+			usb_log_error("%s: Failed to connect to HC.",
+			    instance->id_string);
+			continue;
 		}
 
@@ -190,6 +195,6 @@
 		}
 
-		rc = usb_hc_connection_close(&instance->hc_connection);
-		if (rc != EOK) {
+		ret = usb_hc_connection_close(&instance->hc_connection);
+		if (ret != EOK) {
 			usb_log_error("%s: Failed to disconnect.",
 			    instance->id_string);
@@ -210,4 +215,5 @@
 {
 	uhci_port_t *port = arg;
+	assert(port);
 
 	usb_log_debug2("%s: new_device_enable_port.\n", port->id_string);
@@ -283,4 +289,5 @@
 	usb_log_error("%s: Don't know how to remove device %" PRIun ".\n",
 	    port->id_string, port->attached_device);
+	port->attached_device = 0;
 	return ENOTSUP;
 }
