ACPI / scan: Prevent device add uevents from racing with user space

ACPI core adds sysfs device files after the given devices have been
registered with device_register(), which is not appropriate, because
it may lead to race conditions with user space tools using those
files.

Fix the problem by delaying the KOBJ_ADD uevent for ACPI devices
until after all of the devices' sysfs files have been created.

This also fixes a use-after-free in acpi_device_unregister().

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Rafael J. Wysocki
2013-01-24 12:49:49 +01:00
父節點 e5656271b0
當前提交 cf860be639
共有 3 個文件被更改,包括 20 次插入8 次删除

查看文件

@@ -721,13 +721,14 @@ int acpi_add_power_resource(acpi_handle handle)
acpi_device_bid(device), state ? "on" : "off");
device->flags.match_driver = true;
result = acpi_device_register(device, acpi_release_power_resource);
result = acpi_device_add(device, acpi_release_power_resource);
if (result)
goto err;
mutex_lock(&power_resource_list_lock);
list_add(&resource->list_node, &acpi_power_resource_list);
mutex_unlock(&power_resource_list_lock);
acpi_device_add_finalize(device);
return 0;
err: