DragonFlyBSD Kernel Audit
DF-1003 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/bus/u4b/usb_device.c b/sys/bus/u4b/usb_device.c
--- a/sys/bus/u4b/usb_device.c
+++ b/sys/bus/u4b/usb_device.c
@@ -1988,7 +1988,7 @@
 		    pd->bus_index, pd->dev_index, pd->ep_addr);
 	}
 
-	pd->cdev = make_dev(&usb_ops, 0, uid, gid, mode, "%s", devname);
+	pd->cdev = make_only_dev(&usb_ops, 0, uid, gid, mode, "%s", devname);
 
 	if (pd->cdev == NULL) {
 		DPRINTFN(0, "Failed to create device %s\n", devname);
@@ -1996,8 +1996,9 @@
 		return (NULL);
 	}
 
-	/* XXX setting si_drv1 and creating the device is not atomic! */
+	/* DF-1003: set si_drv1 before publishing the device node. */
 	pd->cdev->si_drv1 = pd;
+	devfs_create_dev(pd->cdev, uid, gid, mode);
 
 	return (pd);
 }