Index: uspace/drv/usbhub/main.c
===================================================================
--- uspace/drv/usbhub/main.c	(revision 71ed4849bc55f4ebfd7caecbcdcc9088afa7f9f0)
+++ uspace/drv/usbhub/main.c	(revision 44bb20b9b07913b44c8e2016aa4ae96cce70a929)
@@ -38,4 +38,5 @@
 
 usb_general_list_t usb_hub_list;
+futex_t usb_hub_list_lock;
 
 static driver_ops_t hub_driver_ops = {
@@ -60,5 +61,7 @@
 {
 	usb_dprintf_enable(NAME,1);
+	futex_initialize(&usb_hub_list_lock, 0);
 	usb_lst_init(&usb_hub_list);
+	futex_up(&usb_hub_list_lock);
 	fid_t fid = fibril_create(usb_hub_control_loop, NULL);
 	if (fid == 0) {
Index: uspace/drv/usbhub/usbhub.c
===================================================================
--- uspace/drv/usbhub/usbhub.c	(revision 71ed4849bc55f4ebfd7caecbcdcc9088afa7f9f0)
+++ uspace/drv/usbhub/usbhub.c	(revision 44bb20b9b07913b44c8e2016aa4ae96cce70a929)
@@ -75,5 +75,5 @@
 	//get some hub info
 	usb_address_t addr = usb_drv_get_my_address(hc, device);
-	dprintf(1,"[usb_hub] addres of newly created hub = %d", addr);
+	dprintf(1,"[usb_hub] address of newly created hub = %d", addr);
 	/*if(addr<0){
 		//return result;
@@ -174,4 +174,5 @@
 		dprintf(1,"[usb_hub] THERE ARE NO CONFIGURATIONS AVAILABLE");
 	}
+	/// \TODO check other configurations
 	usb_standard_configuration_descriptor_t config_descriptor;
 	opResult = usb_drv_req_get_bare_configuration_descriptor(hc,
@@ -194,5 +195,4 @@
 	}
 
-
 	for (port = 1; port < hub_info->port_count+1; ++port) {
 		usb_hub_set_power_port_request(&request, port);
@@ -205,9 +205,11 @@
 	//ports powered, hub seems to be enabled
 
-
 	ipc_hangup(hc);
 
 	//add the hub to list
+	futex_down(&usb_hub_list_lock);
 	usb_lst_append(&usb_hub_list, hub_info);
+	futex_up(&usb_hub_list_lock);
+
 	dprintf(1,"[usb_hub] hub info added to list");
 	//(void)hub_info;
@@ -233,4 +235,20 @@
 //
 //*********************************************
+
+/**
+ * convenience function for releasing default address and writing debug info
+ * (these few lines are used too often to be written again and again)
+ * @param hc
+ * @return
+ */
+inline static int usb_hub_release_default_address(int hc){
+	int opResult;
+	dprintf(1,"[usb_hub] releasing default address");
+	opResult = usb_drv_release_default_address(hc);
+	if (opResult != EOK) {
+		dprintf(1,"[usb_hub] failed to release default address");
+	}
+	return opResult;
+}
 
 /**
@@ -259,23 +277,7 @@
 	if (opResult != EOK) {
 		dprintf(1,"[usb_hub] something went wrong when reseting a port");
-	}
-}
-
-/**
- * convenience function for releasing default address and writing debug info
- * (these few lines are used too often to be written again and again)
- * @param hc
- * @return
- */
-inline static int usb_hub_release_default_address(int hc){
-	int opResult;
-	dprintf(1,"[usb_hub] releasing default address");
-	opResult = usb_drv_release_default_address(hc);
-	if (opResult != EOK) {
-		dprintf(1,"[usb_hub] failed to release default address");
-	}
-	return opResult;
-}
-
+		usb_hub_release_default_address(hc);
+	}
+}
 
 /**
@@ -343,5 +345,5 @@
 
 /**
- * unregister device address in hc, close the port
+ * unregister device address in hc
  * @param hc
  * @param port
@@ -352,15 +354,5 @@
 	//usb_device_request_setup_packet_t request;
 	int opResult;
-	//disable port
-	/*usb_hub_set_disable_port_request(&request, port);
-	opResult = usb_drv_sync_control_write(
-			hc, target,
-			&request,
-			NULL, 0
-			);
-	if (opResult != EOK) {
-		//continue;
-		printf("[usb_hub] something went wrong when disabling a port\n");
-	}*/
+	
 	/// \TODO remove device
 
@@ -457,7 +449,9 @@
 	 */
 	usb_general_list_t * lst_item;
+	futex_down(&usb_hub_list_lock);
 	for (lst_item = usb_hub_list.next;
 			lst_item != &usb_hub_list;
 			lst_item = lst_item->next) {
+		futex_up(&usb_hub_list_lock);
 		usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data);
 		/*
@@ -510,7 +504,10 @@
 			}
 		}
+		free(change_bitmap);
 
 		ipc_hangup(hc);
-	}
+		futex_down(&usb_hub_list_lock);
+	}
+	futex_up(&usb_hub_list_lock);
 }
 
Index: uspace/drv/usbhub/usbhub_private.h
===================================================================
--- uspace/drv/usbhub/usbhub_private.h	(revision 71ed4849bc55f4ebfd7caecbcdcc9088afa7f9f0)
+++ uspace/drv/usbhub/usbhub_private.h	(revision 44bb20b9b07913b44c8e2016aa4ae96cce70a929)
@@ -43,4 +43,6 @@
 #include <bool.h>
 #include <driver.h>
+#include <futex.h>
+
 #include <usb/usb.h>
 #include <usb/usbdrv.h>
@@ -66,5 +68,5 @@
 
 /**
- * @brief create hub structure instance
+ * create hub structure instance
  *
  * Set the address and port count information most importantly.
@@ -79,7 +81,10 @@
 extern usb_general_list_t usb_hub_list;
 
+/** lock for hub list*/
+extern futex_t usb_hub_list_lock;
+
 
 /**
- * @brief perform complete control read transaction
+ * perform complete control read transaction
  *
  * manages all three steps of transaction: setup, read and finalize
@@ -99,7 +104,7 @@
 
 /**
- * @brief perform complete control write transaction
+ * perform complete control write transaction
  *
- * maanges all three steps of transaction: setup, write and finalize
+ * manages all three steps of transaction: setup, write and finalize
  * @param phone
  * @param target
@@ -114,21 +119,4 @@
     void * sent_buffer, size_t sent_size
 );
-
-
-/**
- * set the device request to be a set address request
- * @param request
- * @param addr
- * \TODO this will be obsolete see usb/dev_req.h
- */
-static inline void usb_hub_set_set_address_request(
-usb_device_request_setup_packet_t * request, uint16_t addr
-){
-	request->index = 0;
-	request->request_type = 0;/// \TODO this is not very nice sollution, we ned constant
-	request->request = USB_DEVREQ_SET_ADDRESS;
-	request->value = addr;
-	request->length = 0;
-}
 
 /**
Index: uspace/drv/usbhub/utils.c
===================================================================
--- uspace/drv/usbhub/utils.c	(revision 71ed4849bc55f4ebfd7caecbcdcc9088afa7f9f0)
+++ uspace/drv/usbhub/utils.c	(revision 44bb20b9b07913b44c8e2016aa4ae96cce70a929)
@@ -200,60 +200,5 @@
 
 
-/*
- * method for testing port status bitmap
- 
-static void usb_hub_test_port_status(void) {
-	printf("[usb_hub] -------------port status test---------\n");
-	usb_port_status_t status = 0;
-
-	//printf("original status %d (should be 0)\n",(uint32_t)status);
-	usb_port_set_bit(&status, 1, 1);
-	//printf("%d =?= 2\n",(uint32_t)status);
-	if (status != 2) {
-		printf("[usb_port_status] test failed: wrong set of bit 1\n");
-		return;
-	}
-	usb_port_set_bit(&status, 3, 1);
-	if (status != 10) {
-		printf("[usb_port_status] test failed: wrong set of bit 3\n");
-		return;
-	}
-
-	usb_port_set_bit(&status, 15, 1);
-	if (status != 10 + (1 << 15)) {
-		printf("[usb_port_status] test failed: wrong set of bit 15\n");
-		return;
-	}
-	usb_port_set_bit(&status, 1, 0);
-	if (status != 8 + (1 << 15)) {
-		printf("[usb_port_status] test failed: wrong unset of bit 1\n");
-		return;
-	}
-	int i;
-	for (i = 0; i < 32; ++i) {
-		if (i == 3 || i == 15) {
-			if (!usb_port_get_bit(&status, i)) {
-				printf("[usb_port_status] test failed: wrong bit at %d\n", i);
-			}
-		} else {
-			if (usb_port_get_bit(&status, i)) {
-				printf("[usb_port_status] test failed: wrong bit at %d\n", i);
-			}
-		}
-	}
-
-	printf("test ok\n");
-
-
-	//printf("%d =?= 10\n",(uint32_t)status);
-
-	//printf("this should be 0: %d \n",usb_port_get_bit(&status,0));
-	//printf("this should be 1: %d \n",usb_port_get_bit(&status,1));
-	//printf("this should be 0: %d \n",usb_port_get_bit(&status,2));
-	//printf("this should be 1: %d \n",usb_port_get_bit(&status,3));
-	//printf("this should be 0: %d \n",usb_port_get_bit(&status,4));
-
-}
-*/
+
 
 
