diff options
author | Nicolas Saenz Julienne <nsaenzjulienne@suse.de> | 2021-02-11 21:08:20 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2021-02-12 15:41:59 +0300 |
commit | b306320322c9cfaa465bc2c7367acf6072b1ac0e (patch) | |
tree | d4b96f171e062dfe9e3a5ef8d1902b3fe3c316bb /drivers/spi | |
parent | 386f771aad15dd535f2368b4adc9958c0160edd4 (diff) | |
download | linux-b306320322c9cfaa465bc2c7367acf6072b1ac0e.tar.xz |
spi: Skip zero-length transfers in spi_transfer_one_message()
With the introduction of 26751de25d25 ("spi: bcm2835: Micro-optimise
FIFO loops") it has become apparent that some users might initiate
zero-length SPI transfers. A fact the micro-optimization omitted, and
which turned out to cause crashes[1].
Instead of changing the micro-optimization itself, use a bigger hammer
and skip zero-length transfers altogether for drivers using the default
transfer_one_message() implementation.
Reported-by: Phil Elwell <phil@raspberrypi.com>
Fixes: 26751de25d25 ("spi: bcm2835: Micro-optimise FIFO loops")
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
[1] https://github.com/raspberrypi/linux/issues/4100
Link: https://lore.kernel.org/r/20210211180820.25757-1-nsaenzjulienne@suse.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 720ab34784c1..ccca3a7409fa 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1267,7 +1267,7 @@ static int spi_transfer_one_message(struct spi_controller *ctlr, ptp_read_system_prets(xfer->ptp_sts); } - if (xfer->tx_buf || xfer->rx_buf) { + if ((xfer->tx_buf || xfer->rx_buf) && xfer->len) { reinit_completion(&ctlr->xfer_completion); fallback_pio: |