From 0c9807ae12a27c3e2f1c4332b942a5b10106d0d9 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Thu, 20 Jun 2019 14:36:49 +0200 Subject: [PATCH 24/39] spi/acpi: avoid spurious matches during slave enumeration mainline inclusion from mainline-v5.3-rc1 commit b28944c6f6d3951f0c8f23f90c83ef741d30bfca category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8CSBP CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b28944c6f6d3951f0c8f23f90c83ef741d30bfca ---------------------------------------------------------------------------- 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 Cc: andy.shevchenko@gmail.com Cc: masahisa.kojima@linaro.org Cc: "Rafael J. Wysocki" Cc: Jarkko Nikula Cc: linux-acpi@vger.kernel.org Cc: Lukas Wunner Signed-off-by: Ard Biesheuvel Tested-by: Jarkko Nikula Acked-by: Mika Westerberg Signed-off-by: Mark Brown Signed-off-by: YunYi Yang --- 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 59465736b574..69d569744ea1 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1834,7 +1834,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; @@ -1843,8 +1843,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.27.0