linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: bcm2835: add a sentinel at the end of the lookup array
@ 2023-10-04 18:39 Bartosz Golaszewski
  2023-10-05  9:10 ` Andy Shevchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Bartosz Golaszewski @ 2023-10-04 18:39 UTC (permalink / raw)
  To: Mark Brown, Florian Fainelli, Andy Shevchenko, Linus Walleij,
	Ray Jui, Scott Branden
  Cc: Broadcom internal kernel review list, linux-spi, linux-rpi-kernel,
	linux-arm-kernel, linux-kernel, linux-gpio, Bartosz Golaszewski,
	Hans de Goede

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

GPIOLIB expects the array of lookup entries to be terminated with an
empty member. We need to increase the size of the variable length array
in the lookup table by 1.

Fixes: 21f252cd29f0 ("spi: bcm2835: reduce the abuse of the GPIO API")
Reported-by: Hans de Goede <hdegoede@redhat.com>
Closes: https://lore.kernel.org/lkml/29764d46-8d3d-9794-bbde-d7928a91cbb5@redhat.com/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/spi/spi-bcm2835.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
index c9078fee3662..e709887eb2a9 100644
--- a/drivers/spi/spi-bcm2835.c
+++ b/drivers/spi/spi-bcm2835.c
@@ -1299,7 +1299,7 @@ static int bcm2835_spi_setup(struct spi_device *spi)
 	 * More on the problem that it addresses:
 	 *   https://www.spinics.net/lists/linux-gpio/msg36218.html
 	 */
-	lookup = kzalloc(struct_size(lookup, table, 1), GFP_KERNEL);
+	lookup = kzalloc(struct_size(lookup, table, 2), GFP_KERNEL);
 	if (!lookup) {
 		ret = -ENOMEM;
 		goto err_cleanup;
-- 
2.39.2


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

end of thread, other threads:[~2023-10-12 10:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-04 18:39 [PATCH] spi: bcm2835: add a sentinel at the end of the lookup array Bartosz Golaszewski
2023-10-05  9:10 ` Andy Shevchenko
2023-10-05  9:29   ` Bartosz Golaszewski
2023-10-10 12:04 ` Linus Walleij
2023-10-10 18:33 ` Mark Brown
2023-10-11  7:36   ` Bartosz Golaszewski
2023-10-11 11:45     ` Mark Brown
2023-10-11 11:52       ` Bartosz Golaszewski
2023-10-12  8:40         ` Bartosz Golaszewski
2023-10-12 10:12           ` Mark Brown
2023-10-12 10:48           ` Mark Brown
2023-10-11 14:50 ` Mark Brown

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).