Index: uspace/lib/usbhost/src/bus.c
===================================================================
--- uspace/lib/usbhost/src/bus.c	(revision f82c48222fe87d2474a8989b9da079425289efb6)
+++ uspace/lib/usbhost/src/bus.c	(revision a6c45979c542aedd3bd337f51801ed320a5aee6a)
@@ -199,5 +199,5 @@
 	    ep->max_transfer_size);
 
-	fibril_mutex_lock(&bus->guard);
+	fibril_mutex_lock(&device->guard);
 	if (!device->online && ep->endpoint != 0) {
 		err = EAGAIN;
@@ -209,5 +209,5 @@
 			device->endpoints[ep->endpoint] = ep;
 	}
-	fibril_mutex_unlock(&bus->guard);
+	fibril_mutex_unlock(&device->guard);
 	if (err) {
 		endpoint_del_ref(ep);
@@ -231,7 +231,5 @@
 	assert(device);
 
-	bus_t *bus = device->bus;
-
-	fibril_mutex_lock(&bus->guard);
+	fibril_mutex_lock(&device->guard);
 	endpoint_t *ep = device->endpoints[endpoint];
 	if (ep) {
@@ -239,5 +237,5 @@
 		endpoint_add_ref(ep);
 	}
-	fibril_mutex_unlock(&bus->guard);
+	fibril_mutex_unlock(&device->guard);
 	return ep;
 }
@@ -251,5 +249,9 @@
 	assert(ep->device);
 
-	bus_t *bus = endpoint_get_bus(ep);
+	device_t *device = ep->device;
+	if (!device)
+		return ENOENT;
+
+	bus_t *bus = device->bus;
 
 	const bus_ops_t *ops = BUS_OPS_LOOKUP(bus->ops, endpoint_unregister);
@@ -258,14 +260,14 @@
 
 	usb_log_debug("Unregister endpoint %d:%d %s-%s %zuB.\n",
-	    ep->device->address, ep->endpoint,
+	    device->address, ep->endpoint,
 	    usb_str_transfer_type(ep->transfer_type),
 	    usb_str_direction(ep->direction),
 	    ep->max_transfer_size);
 
-	fibril_mutex_lock(&bus->guard);
+	fibril_mutex_lock(&device->guard);
 	const int r = ops->endpoint_unregister(ep);
 	if (!r)
-		ep->device->endpoints[ep->endpoint] = NULL;
-	fibril_mutex_unlock(&bus->guard);
+		device->endpoints[ep->endpoint] = NULL;
+	fibril_mutex_unlock(&device->guard);
 
 	if (r)
