Skip to content

Commit d4aa921

Browse files
committed
ACPI: scan: Avoid enumerating devices with clearly invalid _STA values
The return value of _STA with the "present" bit unset and the "enabled" bit set is clearly invalid as per the ACPI specification, Section 6.3.7 "_STA (Device Status)", so make the ACPI device enumeration code disregard devices with such _STA return values. Also, because this implies that status.enabled will only be set if status.present is set too, acpi_device_is_enabled() can be modified to simply return the value of the former. Link: https://uefi.org/specs/ACPI/6.5/06_Device_Configuration.html#sta-device-status Link: https://lore.kernel.org/linux-acpi/[email protected]/ Suggested-by: Salil Mehta <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Sudeep Holla <[email protected]>
1 parent 829b75d commit d4aa921

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

drivers/acpi/bus.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,17 @@ int acpi_bus_get_status(struct acpi_device *device)
112112
if (ACPI_FAILURE(status))
113113
return -ENODEV;
114114

115+
if (!device->status.present && device->status.enabled) {
116+
pr_info(FW_BUG "Device [%s] status [%08x]: not present and enabled\n",
117+
device->pnp.bus_id, (u32)sta);
118+
device->status.enabled = 0;
119+
/*
120+
* The status is clearly invalid, so clear the functional bit as
121+
* well to avoid attempting to use the device.
122+
*/
123+
device->status.functional = 0;
124+
}
125+
115126
acpi_set_device_status(device, sta);
116127

117128
if (device->status.functional && !device->status.present) {

drivers/acpi/scan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,7 @@ bool acpi_device_is_present(const struct acpi_device *adev)
19621962

19631963
bool acpi_device_is_enabled(const struct acpi_device *adev)
19641964
{
1965-
return adev->status.present && adev->status.enabled;
1965+
return adev->status.enabled;
19661966
}
19671967

19681968
static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler,

0 commit comments

Comments
 (0)