From aba1d9aaf02ef871a042d048f72278801f84f9d3 Mon Sep 17 00:00:00 2001 From: Joshua DeWeese Date: Fri, 9 Dec 2022 14:30:08 -0500 Subject: [PATCH] drivers/soft_spi: fix device validation bug The code did not take into account that valid bus numbers are 0...(COUNT-1). This patch corrects this. It also makes use of the newly introduced SOFT_SPI_NUMOF define. --- drivers/soft_spi/soft_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/soft_spi/soft_spi.c b/drivers/soft_spi/soft_spi.c index 6a7cff9698..83f67b53be 100644 --- a/drivers/soft_spi/soft_spi.c +++ b/drivers/soft_spi/soft_spi.c @@ -40,7 +40,7 @@ static inline bool soft_spi_bus_is_valid(soft_spi_t bus) { unsigned int soft_spi_num = (unsigned int) bus; - if (ARRAY_SIZE(soft_spi_config) < soft_spi_num) { + if (SOFT_SPI_NUMOF <= soft_spi_num) { return false; } return true;