Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1386184
| From | Vignesh R <vigneshr@ti.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 1/3] spi: return error if kmap'd buffers passed to spi_map_buf() |
| Date | 2016-04-25 12:00 +0200 |
| Message-ID | <rrLt7-3Bp-1@gated-at.bofh.it> (permalink) |
| References | <rrLt7-3Bp-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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>
---
v2: New patch
drivers/spi/spi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index a7ab330d0640..82126bbe69cf 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);
--
2.8.1
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH v2 1/3] spi: return error if kmap'd buffers passed to spi_map_buf() Vignesh R <vigneshr@ti.com> - 2016-04-25 12:00 +0200 Applied "spi: return error if kmap'd buffers passed to spi_map_buf()" to the spi tree Mark Brown <broonie@kernel.org> - 2016-04-25 20:00 +0200
csiph-web