Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 9f788ba

Browse files
andy-shevbroonie
authored andcommitted
spi: Don't mark message DMA mapped when no transfer in it is
There is no need to set the DMA mapped flag of the message if it has no mapped transfers. Moreover, it may give the code a chance to take the wrong paths, i.e. to exercise DMA related APIs on unmapped data. Make __spi_map_msg() to bail earlier on the above mentioned cases. Fixes: 99adef3 ("spi: Provide core support for DMA mapping transfers") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://msgid.link/r/20240522171018.3362521-2-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent d6e7ffd commit 9f788ba

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/spi/spi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,7 @@ static int __spi_map_msg(struct spi_controller *ctlr, struct spi_message *msg)
12431243
else
12441244
rx_dev = ctlr->dev.parent;
12451245

1246+
ret = -ENOMSG;
12461247
list_for_each_entry(xfer, &msg->transfers, transfer_list) {
12471248
/* The sync is done before each transfer. */
12481249
unsigned long attrs = DMA_ATTR_SKIP_CPU_SYNC;
@@ -1272,6 +1273,9 @@ static int __spi_map_msg(struct spi_controller *ctlr, struct spi_message *msg)
12721273
}
12731274
}
12741275
}
1276+
/* No transfer has been mapped, bail out with success */
1277+
if (ret)
1278+
return 0;
12751279

12761280
ctlr->cur_rx_dma_dev = rx_dev;
12771281
ctlr->cur_tx_dma_dev = tx_dev;

0 commit comments

Comments
 (0)