spi: bcm2835: add a sentinel at the end of the lookup array

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: 21f252cd29 ("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>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20231004183906.97845-1-brgl@bgdev.pl
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Bartosz Golaszewski 2023-10-04 20:39:06 +02:00 committed by Mark Brown
parent 8a6b446d8a
commit 9aaa25df9b
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -1299,7 +1299,7 @@ static int bcm2835_spi_setup(struct spi_device *spi)
* More on the problem that it addresses: * More on the problem that it addresses:
* https://www.spinics.net/lists/linux-gpio/msg36218.html * 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) { if (!lookup) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_cleanup; goto err_cleanup;