diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2024-05-22 20:09:49 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-06-12 12:39:46 +0300 |
commit | 4ab9b2180605b0f1a196824320922b2e02bfc5fb (patch) | |
tree | 60c1ae6e07b9501710e4b7c480f157ac47970354 | |
parent | 56a7b74dd37275251c9c61060a4fa65d71cf00f8 (diff) | |
download | linux-4ab9b2180605b0f1a196824320922b2e02bfc5fb.tar.xz |
spi: Don't mark message DMA mapped when no transfer in it is
[ Upstream commit 9f788ba457b45b0ce422943fcec9fa35c4587764 ]
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: 99adef310f68 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/spi/spi.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index a2c467d9e92f..2cea7aeb10f9 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1242,6 +1242,7 @@ static int __spi_map_msg(struct spi_controller *ctlr, struct spi_message *msg) else rx_dev = ctlr->dev.parent; + ret = -ENOMSG; list_for_each_entry(xfer, &msg->transfers, transfer_list) { /* The sync is done before each transfer. */ unsigned long attrs = DMA_ATTR_SKIP_CPU_SYNC; @@ -1271,6 +1272,9 @@ static int __spi_map_msg(struct spi_controller *ctlr, struct spi_message *msg) } } } + /* No transfer has been mapped, bail out with success */ + if (ret) + return 0; ctlr->cur_rx_dma_dev = rx_dev; ctlr->cur_tx_dma_dev = tx_dev; |