aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Brown2018-04-02 15:56:20 +0100
committerMark Brown2018-04-02 15:56:20 +0100
commit43ff2dcef0fde7402a0bbcf2d1f5a507595a9fb0 (patch)
tree79d6c141bd810f8d56e4815c220dcfd5a80b9ed3
parent0adb32858b0bddf4ada5f364a84ed60b196dbcda (diff)
parentce99319a182fe766be67f96338386f3ec73e321c (diff)
Merge remote-tracking branch 'spi/fix/dma' into spi-linus
-rw-r--r--drivers/spi/spi.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index b33a727a0158..4153f959f28c 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -779,8 +779,14 @@ static int spi_map_buf(struct spi_controller *ctlr, struct device *dev,
for (i = 0; i < sgs; i++) {
if (vmalloced_buf || kmap_buf) {
- min = min_t(size_t,
- len, desc_len - offset_in_page(buf));
+ /*
+ * Next scatterlist entry size is the minimum between
+ * the desc_len and the remaining buffer length that
+ * fits in a page.
+ */
+ min = min_t(size_t, desc_len,
+ min_t(size_t, len,
+ PAGE_SIZE - offset_in_page(buf)));
if (vmalloced_buf)
vm_page = vmalloc_to_page(buf);
else