diff options
author | Vignesh R <vigneshr@ti.com> | 2016-04-25 11:44:00 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-04-25 19:55:57 +0200 |
commit | 0569a88f3d1ffed94b15569d53872f16e2351099 (patch) | |
tree | 5e7497a4ef4d1a75c6feced072337ca824e1db8c /drivers/spi/spi.c | |
parent | spi: let SPI masters ignore their children for PM (diff) | |
download | linux-0569a88f3d1ffed94b15569d53872f16e2351099.tar.xz linux-0569a88f3d1ffed94b15569d53872f16e2351099.zip |
spi: return error if kmap'd buffers passed to spi_map_buf()
Current spi_map_buf() implementation supports creates sg_table for
vmalloc'd and kmalloc'd buffers. Therefore return error if kmap'd buffer
(or any other buffer) is passed to spi_map_buf().
Signed-off-by: Vignesh R <vigneshr@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r-- | drivers/spi/spi.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 6c4c050e6b65..a50f880a5036 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -717,9 +717,11 @@ static int spi_map_buf(struct spi_master *master, struct device *dev, if (vmalloced_buf) { desc_len = min_t(int, max_seg_size, PAGE_SIZE); sgs = DIV_ROUND_UP(len + offset_in_page(buf), desc_len); - } else { + } else if (virt_addr_valid(buf)) { desc_len = min_t(int, max_seg_size, master->max_dma_len); sgs = DIV_ROUND_UP(len, desc_len); + } else { + return -EINVAL; } ret = sg_alloc_table(sgt, sgs, GFP_KERNEL); |