Index: uspace/drv/bus/usb/usbhid/kbd/kbddev.c
===================================================================
--- uspace/drv/bus/usb/usbhid/kbd/kbddev.c	(revision e502411123ac12542c03be31503721c9b6bc91f4)
+++ uspace/drv/bus/usb/usbhid/kbd/kbddev.c	(revision cddd1518817e2f8805f9d70c4f0fe3b5ef74edc9)
@@ -540,4 +540,5 @@
 		usb_log_error("Could not bind DDF function: %s.\n",
 		    str_error(rc));
+		fun->driver_data = NULL; /* We need this later */
 		ddf_fun_destroy(fun);
 		return rc;
@@ -554,7 +555,9 @@
 		    "Could not add DDF function to category %s: %s.\n",
 		    HID_KBD_CLASS_NAME, str_error(rc));
+		fun->driver_data = NULL; /* We need this later */
 		ddf_fun_destroy(fun);
 		return rc;
 	}
+	kbd_dev->fun = fun;
 
 	return EOK;
@@ -687,15 +690,5 @@
 	kbd_dev->repeat.delay_between = DEFAULT_REPEAT_DELAY;
 
-	kbd_dev->repeat_mtx = (fibril_mutex_t *)(
-	    malloc(sizeof(fibril_mutex_t)));
-	if (kbd_dev->repeat_mtx == NULL) {
-		usb_log_fatal("No memory!\n");
-		free(kbd_dev->keys);
-		usb_hid_report_output_free(kbd_dev->output_buffer);
-		free(kbd_dev);
-		return ENOMEM;
-	}
-
-	fibril_mutex_initialize(kbd_dev->repeat_mtx);
+	fibril_mutex_initialize(&kbd_dev->repeat_mtx);
 
 	// save the KBD device structure into the HID device structure
@@ -784,22 +777,13 @@
 	async_hangup(kbd_dev->console_sess);
 
-	if (kbd_dev->repeat_mtx != NULL) {
-		//assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx));
-		// FIXME - the fibril_mutex_is_locked may not cause
-		// fibril scheduling
-		while (fibril_mutex_is_locked(kbd_dev->repeat_mtx)) {}
-		free(kbd_dev->repeat_mtx);
-	}
+	//assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx));
+	// FIXME - the fibril_mutex_is_locked may not cause
+	// fibril scheduling
+	while (fibril_mutex_is_locked(&kbd_dev->repeat_mtx)) {}
 
 	// free all buffers
-	if (kbd_dev->keys != NULL) {
-		free(kbd_dev->keys);
-	}
-	if (kbd_dev->keys_old != NULL) {
-		free(kbd_dev->keys_old);
-	}
-	if (kbd_dev->led_data != NULL) {
-		free(kbd_dev->led_data);
-	}
+	free(kbd_dev->keys);
+	free(kbd_dev->keys_old);
+	free(kbd_dev->led_data);
 	if (kbd_dev->led_path != NULL) {
 		usb_hid_report_path_free(kbd_dev->led_path);
Index: uspace/drv/bus/usb/usbhid/kbd/kbddev.h
===================================================================
--- uspace/drv/bus/usb/usbhid/kbd/kbddev.h	(revision e502411123ac12542c03be31503721c9b6bc91f4)
+++ uspace/drv/bus/usb/usbhid/kbd/kbddev.h	(revision cddd1518817e2f8805f9d70c4f0fe3b5ef74edc9)
@@ -92,5 +92,5 @@
 
 	/** Mutex for accessing the information about auto-repeat. */
-	fibril_mutex_t *repeat_mtx;
+	fibril_mutex_t repeat_mtx;
 
 	uint8_t *output_buffer;
@@ -111,4 +111,7 @@
 	 */
 	int initialized;
+
+	/** DDF function */
+	ddf_fun_t *fun;
 } usb_kbd_t;
 
Index: uspace/drv/bus/usb/usbhid/kbd/kbdrepeat.c
===================================================================
--- uspace/drv/bus/usb/usbhid/kbd/kbdrepeat.c	(revision e502411123ac12542c03be31503721c9b6bc91f4)
+++ uspace/drv/bus/usb/usbhid/kbd/kbdrepeat.c	(revision cddd1518817e2f8805f9d70c4f0fe3b5ef74edc9)
@@ -85,5 +85,5 @@
 		}
 		
-		fibril_mutex_lock(kbd->repeat_mtx);
+		fibril_mutex_lock(&kbd->repeat_mtx);
 
 		if (kbd->repeat.key_new > 0) {
@@ -109,5 +109,5 @@
 			delay = CHECK_DELAY;
 		}
-		fibril_mutex_unlock(kbd->repeat_mtx);
+		fibril_mutex_unlock(&kbd->repeat_mtx);
 		
 		async_usleep(delay);
@@ -156,7 +156,7 @@
 void usb_kbd_repeat_start(usb_kbd_t *kbd, unsigned int key)
 {
-	fibril_mutex_lock(kbd->repeat_mtx);
+	fibril_mutex_lock(&kbd->repeat_mtx);
 	kbd->repeat.key_new = key;
-	fibril_mutex_unlock(kbd->repeat_mtx);
+	fibril_mutex_unlock(&kbd->repeat_mtx);
 }
 
@@ -174,9 +174,9 @@
 void usb_kbd_repeat_stop(usb_kbd_t *kbd, unsigned int key)
 {
-	fibril_mutex_lock(kbd->repeat_mtx);
+	fibril_mutex_lock(&kbd->repeat_mtx);
 	if (key == kbd->repeat.key_new) {
 		kbd->repeat.key_new = 0;
 	}
-	fibril_mutex_unlock(kbd->repeat_mtx);
+	fibril_mutex_unlock(&kbd->repeat_mtx);
 }
 
Index: uspace/drv/bus/usb/usbhid/usbhid.c
===================================================================
--- uspace/drv/bus/usb/usbhid/usbhid.c	(revision e502411123ac12542c03be31503721c9b6bc91f4)
+++ uspace/drv/bus/usb/usbhid/usbhid.c	(revision cddd1518817e2f8805f9d70c4f0fe3b5ef74edc9)
@@ -669,17 +669,13 @@
 	}
 
-	// free the subdrivers info
-	if (hid_dev->subdrivers != NULL) {
-		free(hid_dev->subdrivers);
-	}
-
-	// destroy the parser
+	/* Free allocated structures */
+	free(hid_dev->subdrivers);
+	free(hid_dev->report_desc);
+
+	/* Destroy the parser */
 	if (hid_dev->report != NULL) {
 		usb_hid_free_report(hid_dev->report);
 	}
 
-	if (hid_dev->report_desc != NULL) {
-		free(hid_dev->report_desc);
-	}
 }
 
