Skip to content

Commit

Permalink
spi: bcm2835: Do not call gpiod_put() on invalid descriptor
Browse files Browse the repository at this point in the history
If we are unable to lookup the chip-select GPIO, the error path will
call bcm2835_spi_cleanup() which unconditionally calls gpiod_put() on
the cs->gpio variable which we just determined was invalid.

Fixes: 21f252c ("spi: bcm2835: reduce the abuse of the GPIO API")
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20250401224238.2854256-1-florian.fainelli@broadcom.com
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Florian Fainelli authored and Mark Brown committed Apr 1, 2025
1 parent 3cb2a2f commit d669101
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/spi/spi-bcm2835.c
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,8 @@ static void bcm2835_spi_cleanup(struct spi_device *spi)
sizeof(u32),
DMA_TO_DEVICE);

gpiod_put(bs->cs_gpio);
if (!IS_ERR(bs->cs_gpio))
gpiod_put(bs->cs_gpio);
spi_set_csgpiod(spi, 0, NULL);

kfree(target);
Expand Down

0 comments on commit d669101

Please sign in to comment.