Skip to content

Commit b306320

Browse files
Nicolas Saenz Juliennebroonie
Nicolas Saenz Julienne
authored andcommitted
spi: Skip zero-length transfers in spi_transfer_one_message()
With the introduction of 26751de ("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 <[email protected]> Fixes: 26751de ("spi: bcm2835: Micro-optimise FIFO loops") Signed-off-by: Nicolas Saenz Julienne <[email protected]> [1] raspberrypi/linux#4100 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 386f771 commit b306320

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/spi/spi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ static int spi_transfer_one_message(struct spi_controller *ctlr,
12671267
ptp_read_system_prets(xfer->ptp_sts);
12681268
}
12691269

1270-
if (xfer->tx_buf || xfer->rx_buf) {
1270+
if ((xfer->tx_buf || xfer->rx_buf) && xfer->len) {
12711271
reinit_completion(&ctlr->xfer_completion);
12721272

12731273
fallback_pio:

0 commit comments

Comments
 (0)