• Rafael J. Wysocki's avatar
    ACPI: scan: Fix race related to dropping dependencies · 5f4ce260
    Rafael J. Wysocki authored
    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: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
    5f4ce260
scan.c 64.5 KB