Skip to content

Commit d669101

Browse files
ffainellibroonie
authored andcommitted
spi: bcm2835: Do not call gpiod_put() on invalid descriptor
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>
1 parent 3cb2a2f commit d669101

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/spi/spi-bcm2835.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,8 @@ static void bcm2835_spi_cleanup(struct spi_device *spi)
11621162
sizeof(u32),
11631163
DMA_TO_DEVICE);
11641164

1165-
gpiod_put(bs->cs_gpio);
1165+
if (!IS_ERR(bs->cs_gpio))
1166+
gpiod_put(bs->cs_gpio);
11661167
spi_set_csgpiod(spi, 0, NULL);
11671168

11681169
kfree(target);

0 commit comments

Comments
 (0)