All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi/acpi: avoid spurious matches during slave enumeration
@ 2019-06-20 12:36 Ard Biesheuvel
  2019-06-20 12:54 ` Jarkko Nikula
  2019-06-20 12:56 ` Mika Westerberg
  0 siblings, 2 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2019-06-20 12:36 UTC (permalink / raw)
  To: linux-spi
  Cc: broonie, Ard Biesheuvel, Mika Westerberg, andy.shevchenko,
	masahisa.kojima, Rafael J. Wysocki, Jarkko Nikula, linux-acpi,
	Lukas Wunner

In the new SPI ACPI slave enumeration code, we use the value of
lookup.max_speed_khz as a flag to decide whether a match occurred.
However, doing so only makes sense if we initialize its value to
zero beforehand, or otherwise, random junk from the stack will
cause spurious matches.

So zero initialize the lookup struct fully, and only set the non-zero
members explicitly.

Fixes: 4c3c59544f33 ("spi/acpi: enumerate all SPI slaves in the namespace")
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 | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index a31e1e291335..4057f256ef76 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1953,7 +1953,7 @@ static acpi_status acpi_register_spi_device(struct spi_controller *ctlr,
 {
 	acpi_handle parent_handle = NULL;
 	struct list_head resource_list;
-	struct acpi_spi_lookup lookup;
+	struct acpi_spi_lookup lookup = {};
 	struct spi_device *spi;
 	int ret;
 
@@ -1962,8 +1962,6 @@ static acpi_status acpi_register_spi_device(struct spi_controller *ctlr,
 		return AE_OK;
 
 	lookup.ctlr		= ctlr;
-	lookup.mode		= 0;
-	lookup.bits_per_word	= 0;
 	lookup.irq		= -1;
 
 	INIT_LIST_HEAD(&resource_list);
-- 
2.20.1


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

* Re: [PATCH] spi/acpi: avoid spurious matches during slave enumeration
  2019-06-20 12:36 [PATCH] spi/acpi: avoid spurious matches during slave enumeration Ard Biesheuvel
@ 2019-06-20 12:54 ` Jarkko Nikula
  2019-06-20 12:56 ` Mika Westerberg
  1 sibling, 0 replies; 3+ messages in thread
From: Jarkko Nikula @ 2019-06-20 12:54 UTC (permalink / raw)
  To: Ard Biesheuvel, linux-spi
  Cc: broonie, Mika Westerberg, andy.shevchenko, masahisa.kojima,
	Rafael J. Wysocki, linux-acpi, Lukas Wunner

On 6/20/19 3:36 PM, Ard Biesheuvel wrote:
> In the new SPI ACPI slave enumeration code, we use the value of
> lookup.max_speed_khz as a flag to decide whether a match occurred.
> However, doing so only makes sense if we initialize its value to
> zero beforehand, or otherwise, random junk from the stack will
> cause spurious matches.
> 
> So zero initialize the lookup struct fully, and only set the non-zero
> members explicitly.
> 
> Fixes: 4c3c59544f33 ("spi/acpi: enumerate all SPI slaves in the namespace")
> 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 | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>

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

* Re: [PATCH] spi/acpi: avoid spurious matches during slave enumeration
  2019-06-20 12:36 [PATCH] spi/acpi: avoid spurious matches during slave enumeration Ard Biesheuvel
  2019-06-20 12:54 ` Jarkko Nikula
@ 2019-06-20 12:56 ` Mika Westerberg
  1 sibling, 0 replies; 3+ messages in thread
From: Mika Westerberg @ 2019-06-20 12:56 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-spi, broonie, andy.shevchenko, masahisa.kojima,
	Rafael J. Wysocki, Jarkko Nikula, linux-acpi, Lukas Wunner

On Thu, Jun 20, 2019 at 02:36:49PM +0200, Ard Biesheuvel wrote:
> In the new SPI ACPI slave enumeration code, we use the value of
> lookup.max_speed_khz as a flag to decide whether a match occurred.
> However, doing so only makes sense if we initialize its value to
> zero beforehand, or otherwise, random junk from the stack will
> cause spurious matches.
> 
> So zero initialize the lookup struct fully, and only set the non-zero
> members explicitly.
> 
> Fixes: 4c3c59544f33 ("spi/acpi: enumerate all SPI slaves in the namespace")
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-20 12:36 [PATCH] spi/acpi: avoid spurious matches during slave enumeration Ard Biesheuvel
2019-06-20 12:54 ` Jarkko Nikula
2019-06-20 12:56 ` Mika Westerberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.