diff options
author | Mark Brown <broonie@kernel.org> | 2018-04-02 16:56:20 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-04-02 16:56:20 +0200 |
commit | 43ff2dcef0fde7402a0bbcf2d1f5a507595a9fb0 (patch) | |
tree | 79d6c141bd810f8d56e4815c220dcfd5a80b9ed3 /drivers/spi | |
parent | Linux 4.16 (diff) | |
parent | spi: Fix scatterlist elements size in spi_map_buf (diff) | |
download | linux-43ff2dcef0fde7402a0bbcf2d1f5a507595a9fb0.tar.xz linux-43ff2dcef0fde7402a0bbcf2d1f5a507595a9fb0.zip |
Merge remote-tracking branch 'spi/fix/dma' into spi-linus
Diffstat (limited to 'drivers/spi')
-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 |