提交 c013d040 编写于 作者: G Greg Kroah-Hartman

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: NGreg Kroah-Hartman <gregkh@suse.de>
上级 bfd3a5a9
...@@ -818,12 +818,12 @@ static int usb_register_bus(struct usb_bus *bus) ...@@ -818,12 +818,12 @@ static int usb_register_bus(struct usb_bus *bus)
set_bit (busnum, busmap.busmap); set_bit (busnum, busmap.busmap);
bus->busnum = busnum; bus->busnum = busnum;
bus->dev = device_create(usb_host_class, bus->controller, MKDEV(0, 0), bus->dev = device_create_drvdata(usb_host_class, bus->controller,
MKDEV(0, 0), bus,
"usb_host%d", busnum); "usb_host%d", busnum);
result = PTR_ERR(bus->dev); result = PTR_ERR(bus->dev);
if (IS_ERR(bus->dev)) if (IS_ERR(bus->dev))
goto error_create_class_dev; goto error_create_class_dev;
dev_set_drvdata(bus->dev, bus);
/* Add it to the local list of buses */ /* Add it to the local list of buses */
list_add (&bus->bus_list, &usb_bus_list); list_add (&bus->bus_list, &usb_bus_list);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册