]> Pileus Git - ~andy/linux/commitdiff
ACPI / scan: Start matching drivers after trying scan handlers
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 7 Nov 2013 00:41:01 +0000 (01:41 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 7 Nov 2013 00:41:01 +0000 (01:41 +0100)
ACPI scan handlers should always be attached to struct acpi_device
objects before any ACPI drivers, but there is a window during which
a driver may be attached to a struct acpi_device before checking if
there is a matching scan handler.  Namely, that will happen if an
ACPI driver module is loaded during acpi_bus_scan() right after
the first namespace walk is complete and before the given device
is processed by the second namespace walk.

To prevent that from happening, set the match_driver flags of
struct acpi_device objects right before running device_attach()
for them in acpi_bus_device_attach().

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Toshi Kani <toshi.kani@hp.com>
drivers/acpi/scan.c

index fbdb82e70d10623c0bbf94aa73723a40fd32e77d..4d377a22622a6c92b8957d48661830700936fd67 100644 (file)
@@ -1677,7 +1677,6 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
 
 void acpi_device_add_finalize(struct acpi_device *device)
 {
-       device->flags.match_driver = true;
        dev_set_uevent_suppress(&device->dev, false);
        kobject_uevent(&device->dev.kobj, KOBJ_ADD);
 }
@@ -1916,8 +1915,12 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
                return AE_OK;
 
        ret = acpi_scan_attach_handler(device);
-       if (ret)
-               return ret > 0 ? AE_OK : AE_CTRL_DEPTH;
+       if (ret < 0)
+               return AE_CTRL_DEPTH;
+
+       device->flags.match_driver = true;
+       if (ret > 0)
+               return AE_OK;
 
        ret = device_attach(&device->dev);
        return ret >= 0 ? AE_OK : AE_CTRL_DEPTH;