Skip to content

Commit 729fdbf

Browse files
andy-shevgregkh
authored andcommitted
spi: Don't mark message DMA mapped when no transfer in it is
[ Upstream commit 9f788ba ] 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 <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 8dfcd77 commit 729fdbf

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
@@ -1147,6 +1147,7 @@ static int __spi_map_msg(struct spi_controller *ctlr, struct spi_message *msg)
11471147
else
11481148
rx_dev = ctlr->dev.parent;
11491149

1150+
ret = -ENOMSG;
11501151
list_for_each_entry(xfer, &msg->transfers, transfer_list) {
11511152
/* The sync is done before each transfer. */
11521153
unsigned long attrs = DMA_ATTR_SKIP_CPU_SYNC;
@@ -1176,6 +1177,9 @@ static int __spi_map_msg(struct spi_controller *ctlr, struct spi_message *msg)
11761177
}
11771178
}
11781179
}
1180+
/* No transfer has been mapped, bail out with success */
1181+
if (ret)
1182+
return 0;
11791183

11801184
ctlr->cur_rx_dma_dev = rx_dev;
11811185
ctlr->cur_tx_dma_dev = tx_dev;

0 commit comments

Comments
 (0)