Skip to content

Commit 110af99

Browse files
andy-shevroxanan1996
authored andcommitted
spi: Don't mark message DMA mapped when no transfer in it is
BugLink: https://bugs.launchpad.net/bugs/2072617 [ 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: 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> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Portia Stephens <portia.stephens@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 5a7ef1e commit 110af99

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
@@ -1047,6 +1047,7 @@ static int __spi_map_msg(struct spi_controller *ctlr, struct spi_message *msg)
10471047
else
10481048
rx_dev = ctlr->dev.parent;
10491049

1050+
ret = -ENOMSG;
10501051
list_for_each_entry(xfer, &msg->transfers, transfer_list) {
10511052
if (!ctlr->can_dma(ctlr, msg->spi, xfer))
10521053
continue;
@@ -1070,6 +1071,9 @@ static int __spi_map_msg(struct spi_controller *ctlr, struct spi_message *msg)
10701071
}
10711072
}
10721073
}
1074+
/* No transfer has been mapped, bail out with success */
1075+
if (ret)
1076+
return 0;
10731077

10741078
ctlr->cur_msg_mapped = true;
10751079

0 commit comments

Comments
 (0)