diff options
author | Mark Brown | 2018-04-02 15:56:20 +0100 |
---|---|---|
committer | Mark Brown | 2018-04-02 15:56:20 +0100 |
commit | 43ff2dcef0fde7402a0bbcf2d1f5a507595a9fb0 (patch) | |
tree | 79d6c141bd810f8d56e4815c220dcfd5a80b9ed3 | |
parent | 0adb32858b0bddf4ada5f364a84ed60b196dbcda (diff) | |
parent | ce99319a182fe766be67f96338386f3ec73e321c (diff) |
Merge remote-tracking branch 'spi/fix/dma' into spi-linus
-rw-r--r-- | drivers/spi/spi.c | 10 |
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 |