diff options
author | Ard Biesheuvel <[email protected]> | 2019-06-19 11:52:54 +0200 |
---|---|---|
committer | Mark Brown <[email protected]> | 2019-06-19 11:54:29 +0100 |
commit | b5e3cf410b486a2415ff09b12f3ef18aba9f53ff (patch) | |
tree | ff9288b12f6edc5d55cadc40b7626a439648fa2b | |
parent | f56943699463478617b235930252261d5277bd46 (diff) |
spi/acpi: fix incorrect ACPI parent check
The ACPI device object parsing code for SPI slaves enumerates the
entire ACPI namespace to look for devices that refer to the master
in question via the 'resource_source' field in the 'SPISerialBus'
resource. If that field does not refer to a valid ACPI device or
if it refers to the wrong SPI master, we should disregard the
device.
Current, the valid device check is wrong, since it gets the
polarity of 'status' wrong. This could cause issues if the
'resource_source' field is bogus but parent_handle happens to
refer to the correct master (which is not entirely imaginary
since this code runs in a loop)
So test for ACPI_FAILURE() instead, to make the code more
self explanatory.
Fixes: 4c3c59544f33 ("spi/acpi: enumerate all SPI slaves in the namespace")
Reported-by: kbuild test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
Cc: Mika Westerberg <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: "Rafael J. Wysocki" <[email protected]>
Cc: Jarkko Nikula <[email protected]>
Cc: [email protected]
Cc: Lukas Wunner <[email protected]>
Signed-off-by: Ard Biesheuvel <[email protected]>
Acked-by: Mika Westerberg <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
-rw-r--r-- | drivers/spi/spi.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 01a40bcfc352..a31e1e291335 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1907,7 +1907,7 @@ static int acpi_spi_add_resource(struct acpi_resource *ares, void *data) sb->resource_source.string_ptr, &parent_handle); - if (!status || + if (ACPI_FAILURE(status) || ACPI_HANDLE(ctlr->dev.parent) != parent_handle) return -ENODEV; |