svn commit: r294088 - head/sys/dev/usb
Hans Petter Selasky
hselasky at FreeBSD.org
Fri Jan 15 12:09:17 UTC 2016
Author: hselasky
Date: Fri Jan 15 12:09:15 2016
New Revision: 294088
URL: https://svnweb.freebsd.org/changeset/base/294088
Log:
Use the recently added "make_dev_s()" function to solve old race setting the
si_drv1 field in "struct cdev" when creating new character devices.
Modified:
head/sys/dev/usb/usb_device.c
Modified: head/sys/dev/usb/usb_device.c
==============================================================================
--- head/sys/dev/usb/usb_device.c Fri Jan 15 11:40:41 2016 (r294087)
+++ head/sys/dev/usb/usb_device.c Fri Jan 15 12:09:15 2016 (r294088)
@@ -1962,6 +1962,7 @@ usb_make_dev(struct usb_device *udev, co
int fi, int rwmode, uid_t uid, gid_t gid, int mode)
{
struct usb_fs_privdata* pd;
+ struct make_dev_args args;
char buffer[32];
/* Store information to locate ourselves again later */
@@ -1980,17 +1981,19 @@ usb_make_dev(struct usb_device *udev, co
pd->bus_index, pd->dev_index, pd->ep_addr);
}
- pd->cdev = make_dev(&usb_devsw, 0, uid, gid, mode, "%s", devname);
+ /* Setup arguments for make_dev_s() */
+ make_dev_args_init(&args);
+ args.mda_devsw = &usb_devsw;
+ args.mda_uid = uid;
+ args.mda_gid = gid;
+ args.mda_mode = mode;
+ args.mda_si_drv1 = pd;
- if (pd->cdev == NULL) {
+ if (make_dev_s(&args, &pd->cdev, "%s", devname) != 0) {
DPRINTFN(0, "Failed to create device %s\n", devname);
free(pd, M_USBDEV);
return (NULL);
}
-
- /* XXX setting si_drv1 and creating the device is not atomic! */
- pd->cdev->si_drv1 = pd;
-
return (pd);
}
More information about the svn-src-all
mailing list