aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2008-05-16 20:55:12 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-05-20 16:31:56 -0400
commitc013d040b70bc2bff5465917ebb255a70b650396 (patch)
tree085b1bdfe377e7d7f90be0e23ead1b951eafc7fb /drivers
parentbfd3a5a96c1dd432303fdf2283e770419f6aecb3 (diff)
USB: Core: fix race in device_create
There is a race from when a device is created with device_create() and then the drvdata is set with a call to dev_set_drvdata() in which a sysfs file could be open, yet the drvdata will be NULL, causing all sorts of bad things to happen. This patch fixes the problem by using the new function, device_create_drvdata(). Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/core/hcd.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index bf10e9c4195e..09a53e7f3327 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -818,12 +818,12 @@ static int usb_register_bus(struct usb_bus *bus)
818 set_bit (busnum, busmap.busmap); 818 set_bit (busnum, busmap.busmap);
819 bus->busnum = busnum; 819 bus->busnum = busnum;
820 820
821 bus->dev = device_create(usb_host_class, bus->controller, MKDEV(0, 0), 821 bus->dev = device_create_drvdata(usb_host_class, bus->controller,
822 "usb_host%d", busnum); 822 MKDEV(0, 0), bus,
823 "usb_host%d", busnum);
823 result = PTR_ERR(bus->dev); 824 result = PTR_ERR(bus->dev);
824 if (IS_ERR(bus->dev)) 825 if (IS_ERR(bus->dev))
825 goto error_create_class_dev; 826 goto error_create_class_dev;
826 dev_set_drvdata(bus->dev, bus);
827 827
828 /* Add it to the local list of buses */ 828 /* Add it to the local list of buses */
829 list_add (&bus->bus_list, &usb_bus_list); 829 list_add (&bus->bus_list, &usb_bus_list);