linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi/acpi: fix incorrect ACPI parent check
@ 2019-06-19  9:52 Ard Biesheuvel
  2019-06-19 10:16 ` Mika Westerberg
  0 siblings, 1 reply; 14+ messages in thread
From: Ard Biesheuvel @ 2019-06-19  9:52 UTC (permalink / raw)
  To: linux-spi
  Cc: broonie, Ard Biesheuvel, kbuild test robot, Dan Carpenter,
	Mika Westerberg, andy.shevchenko, masahisa.kojima,
	Rafael J. Wysocki, Jarkko Nikula, linux-acpi, Lukas Wunner

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 <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: andy.shevchenko@gmail.com
Cc: masahisa.kojima@linaro.org
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Cc: linux-acpi@vger.kernel.org
Cc: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 drivers/spi/spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index c8adcc97f3ef..50d230b33c42 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1859,7 +1859,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;
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-06-20 12:26 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-19  9:52 [PATCH] spi/acpi: fix incorrect ACPI parent check Ard Biesheuvel
2019-06-19 10:16 ` Mika Westerberg
2019-06-19 11:58   ` Jarkko Nikula
2019-06-19 11:59     ` Ard Biesheuvel
2019-06-19 13:21       ` Jarkko Nikula
2019-06-19 13:58         ` Ard Biesheuvel
2019-06-19 14:17           ` Jarkko Nikula
2019-06-19 14:42             ` Mika Westerberg
2019-06-20 10:33               ` Ard Biesheuvel
2019-06-20 10:41                 ` Mika Westerberg
2019-06-20 11:19                   ` Mark Brown
2019-06-20 11:51                     ` Ard Biesheuvel
2019-06-20 12:21                 ` Jarkko Nikula
2019-06-20 12:25                   ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).