ACPI: scan: Fix race related to dropping dependencies
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 17 Jun 2021 13:57:07 +0000 (15:57 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 17 Jun 2021 13:57:07 +0000 (15:57 +0200)
commit5f4ce26078fde9cd406c008ba35e31bbb26a23a1
tree02b429ff48fc0b3518058f8d011239f2ac3c4e0b
parentc6a493a1b603ed216ce69d1faac3f0ddc6a2f8eb
ACPI: scan: Fix race related to dropping dependencies

If acpi_add_single_object() runs concurrently with respect to
acpi_scan_clear_dep() which deletes a dependencies list entry where
the device being added is the consumer, the device's dep_unmet
counter may not be updated to reflect that change.

Namely, if the dependencies list entry is deleted right after
calling acpi_scan_dep_init() and before calling acpi_device_add(),
acpi_scan_clear_dep() will not find the device object corresponding
to the consumer device ACPI handle and it will not update its
dep_unmet counter to reflect the deletion of the list entry.
Consequently, the dep_unmet counter of the device will never
become zero going forward which may prevent it from being
completely enumerated.

To address this problem, modify acpi_add_single_object() to run
acpi_tie_acpi_dev(), to attach the ACPI device object created by it
to the corresponding ACPI namespace node, under acpi_dep_list_lock
along with acpi_scan_dep_init() whenever the latter is called.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
drivers/acpi/scan.c