mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 13:41:51 +00:00
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: 99adef310f
("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>
This commit is contained in:
parent
d6e7ffd482
commit
9f788ba457
@ -1243,6 +1243,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;
|
||||
@ -1272,6 +1273,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;
|
||||
|
Loading…
Reference in New Issue
Block a user