summaryrefslogtreecommitdiffstats
path: root/drivers/acpi/power.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-24 12:49:49 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-24 12:49:49 +0100
commitcf860be639d86ed77af179c925085ae0721ae602 (patch)
tree3acb93b90f48f2bc4838ba80cd66dce60a40825a /drivers/acpi/power.c
parentACPI / PM: Fix device power state value after transitions to D3cold (diff)
downloadlinux-cf860be639d86ed77af179c925085ae0721ae602.tar.xz
linux-cf860be639d86ed77af179c925085ae0721ae602.zip
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>
Diffstat (limited to 'drivers/acpi/power.c')
-rw-r--r--drivers/acpi/power.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 6db261c237d4..3f16dd4db23e 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -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: