Index: uspace/drv/bus/usb/usbhid/mouse/mousedev.c
===================================================================
--- uspace/drv/bus/usb/usbhid/mouse/mousedev.c	(revision 5723ae49a1b8c14c229e53d58adc3fada6f6c9f8)
+++ uspace/drv/bus/usb/usbhid/mouse/mousedev.c	(revision e3e0953afa373443a78ac42c3a5cd6ab3fd66c0d)
@@ -220,9 +220,9 @@
 	}
 
-	int shift_x = get_mouse_axis_move_value(hid_dev->report_id,
+	const int shift_x = get_mouse_axis_move_value(hid_dev->report_id,
 	    &hid_dev->report, USB_HIDUT_USAGE_GENERIC_DESKTOP_X);
-	int shift_y = get_mouse_axis_move_value(hid_dev->report_id,
+	const int shift_y = get_mouse_axis_move_value(hid_dev->report_id,
 	    &hid_dev->report, USB_HIDUT_USAGE_GENERIC_DESKTOP_Y);
-	int wheel = get_mouse_axis_move_value(hid_dev->report_id,
+	const int wheel = get_mouse_axis_move_value(hid_dev->report_id,
 	    &hid_dev->report, USB_HIDUT_USAGE_GENERIC_DESKTOP_WHEEL);
 
@@ -230,6 +230,8 @@
 		async_exch_t *exch =
 		    async_exchange_begin(mouse_dev->mouse_sess);
-		async_req_2_0(exch, MOUSEEV_MOVE_EVENT, shift_x, shift_y);
-		async_exchange_end(exch);
+		if (exch != NULL) {
+			async_req_2_0(exch, MOUSEEV_MOVE_EVENT, shift_x, shift_y);
+			async_exchange_end(exch);
+		}
 	}
 
@@ -237,9 +239,17 @@
 		usb_mouse_send_wheel(mouse_dev, wheel);
 
-	/*
-	 * Buttons
-	 */
+	/* Buttons */
 	usb_hid_report_path_t *path = usb_hid_report_path();
-	usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_BUTTON, 0);
+	if (path == NULL) {
+		usb_log_warning("Failed to create USB HID report path.\n");
+		return true;
+	}
+	int ret =
+	   usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_BUTTON, 0);
+	if (ret != EOK) {
+		usb_hid_report_path_free(path);
+		usb_log_warning("Failed to add buttons to report path.\n");
+		return true;
+	}
 	usb_hid_report_path_set_report_id(path, hid_dev->report_id);
 
@@ -254,19 +264,24 @@
 		const unsigned index = field->usage - field->usage_minimum;
 		assert(index < mouse_dev->buttons_count);
-		
+
 		if (mouse_dev->buttons[index] == 0 && field->value != 0) {
 			async_exch_t *exch =
 			    async_exchange_begin(mouse_dev->mouse_sess);
-			async_req_2_0(exch, MOUSEEV_BUTTON_EVENT, field->usage, 1);
-			async_exchange_end(exch);
-			
-			mouse_dev->buttons[index] = field->value;
+			if (exch != NULL) {
+				async_req_2_0(exch, MOUSEEV_BUTTON_EVENT,
+				    field->usage, 1);
+				async_exchange_end(exch);
+				mouse_dev->buttons[index] = field->value;
+			}
+
 		} else if (mouse_dev->buttons[index] != 0 && field->value == 0) {
 			async_exch_t *exch =
 			    async_exchange_begin(mouse_dev->mouse_sess);
-			async_req_2_0(exch, MOUSEEV_BUTTON_EVENT, field->usage, 0);
-			async_exchange_end(exch);
-
-			mouse_dev->buttons[index] = field->value;
+			if (exch != NULL) {
+				async_req_2_0(exch, MOUSEEV_BUTTON_EVENT,
+				    field->usage, 0);
+				async_exchange_end(exch);
+				mouse_dev->buttons[index] = field->value;
+			}
 		}
 
@@ -336,4 +351,5 @@
 		mouse->mouse_fun->driver_data = NULL;
 		ddf_fun_destroy(mouse->mouse_fun);
+		mouse->mouse_fun = NULL;
 		return ENOMEM;
 	}
@@ -353,4 +369,5 @@
 		mouse->mouse_fun->driver_data = NULL;
 		ddf_fun_destroy(mouse->mouse_fun);
+		mouse->mouse_fun = NULL;
 		fun->driver_data = NULL;
 		ddf_fun_destroy(fun);
@@ -368,4 +385,5 @@
 		mouse->mouse_fun->driver_data = NULL;
 		ddf_fun_destroy(mouse->mouse_fun);
+		mouse->mouse_fun = NULL;
 		ddf_fun_unbind(fun);
 		fun->driver_data = NULL;
@@ -438,8 +456,4 @@
 		return ENOMEM;
 	}
-	mouse_dev->mouse_sess = NULL;
-	mouse_dev->wheel_sess = NULL;
-	mouse_dev->buttons = NULL;
-	mouse_dev->buttons_count = 0;
 
 	// FIXME: This may not be optimal since stupid hardware vendor may
@@ -484,6 +498,6 @@
 {
 	if (hid_dev == NULL || data == NULL) {
-		usb_log_error("Missing argument to the mouse polling callback."
-		    "\n");
+		usb_log_error(
+		    "Missing argument to the mouse polling callback.\n");
 		return false;
 	}
