DragonFlyBSD Kernel Audit
DF-1050 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/bus/u4b/controller/usb_controller.c b/sys/bus/u4b/controller/usb_controller.c
--- a/sys/bus/u4b/controller/usb_controller.c
+++ b/sys/bus/u4b/controller/usb_controller.c
@@ -70,7 +70,7 @@
 static device_resume_t usb_resume;
 static device_shutdown_t usb_shutdown;
 
-static void	usb_attach_sub(device_t, struct usb_bus *);
+static int	usb_attach_sub(device_t, struct usb_bus *);
 
 /* static variables */
 
@@ -177,7 +177,8 @@
 		bus->bus_roothold = root_mount_hold(device_get_nameunit(dev));
 	}
 #endif
-	usb_attach_sub(dev, bus);
+	if (usb_attach_sub(dev, bus) != 0)
+		return (ENXIO);
 
 	return (0);			/* return success */
 }
@@ -807,7 +808,7 @@
  *
  * This function creates a thread which runs the USB attach code.
  *------------------------------------------------------------------------*/
-static void
+static int
 usb_attach_sub(device_t dev, struct usb_bus *bus)
 {
 	if (usb_devclass_ptr == NULL)
@@ -880,18 +881,22 @@
 	    &bus->bus_lock, device_get_nameunit(dev), USB_PRI_MED)) {
 		device_printf(dev, "WARNING: Creation of USB Giant "
 		    "callback process failed.\n");
+		return (ENXIO);
 	} else if (usb_proc_create(USB_BUS_NON_GIANT_PROC(bus),
 	    &bus->bus_lock, device_get_nameunit(dev), USB_PRI_HIGH)) {
 		device_printf(dev, "WARNING: Creation of USB non-Giant "
 		    "callback process failed.\n");
+		return (ENXIO);
 	} else if (usb_proc_create(USB_BUS_EXPLORE_PROC(bus),
 	    &bus->bus_lock, device_get_nameunit(dev), USB_PRI_MED)) {
 		device_printf(dev, "WARNING: Creation of USB explore "
 		    "process failed.\n");
+		return (ENXIO);
 	} else if (usb_proc_create(USB_BUS_CONTROL_XFER_PROC(bus),
 	    &bus->bus_lock, device_get_nameunit(dev), USB_PRI_MED)) {
 		device_printf(dev, "WARNING: Creation of USB control transfer "
 		    "process failed.\n");
+		return (ENXIO);
 	} else
 #endif
 	{
@@ -904,6 +909,7 @@
 		/* Do initial explore */
 		usb_needs_explore(bus, 1);
 	}
+	return (0);
 }
 
 SYSUNINIT(usb_bus_unload, SI_SUB_CONFIGURE, SI_ORDER_ANY, usb_bus_unload, NULL);