summaryrefslogtreecommitdiffstats
path: root/drivers/media/v4l2-core/videobuf2-dma-sg.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab2013-04-19 12:18:01 +0200
committerMauro Carvalho Chehab2013-04-25 14:54:00 +0200
commit7f8414594e4755234fd0ca415630cfe2dfab42ce (patch)
tree4fc8507e954362d9f5898703e0c10dbd1651b2b8 /drivers/media/v4l2-core/videobuf2-dma-sg.c
parent[media] em28xx: save isoc endpoint number for DVB only if endpoint has alt se... (diff)
downloadkernel-qcow2-linux-7f8414594e4755234fd0ca415630cfe2dfab42ce.tar.gz
kernel-qcow2-linux-7f8414594e4755234fd0ca415630cfe2dfab42ce.tar.xz
kernel-qcow2-linux-7f8414594e4755234fd0ca415630cfe2dfab42ce.zip
[media] media: videobuf2: fix the length check for mmap
Memory maps typically require that the buffer size to be page aligned. Currently, two memops drivers do such alignment internally, but videobuf-vmalloc doesn't. Also, the buffer overflow check doesn't take it into account. So, instead of doing it at each memops driver, enforce it at VB2 core. Reported-by: Prabhakar lad <prabhakar.csengg@gmail.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/v4l2-core/videobuf2-dma-sg.c')
-rw-r--r--drivers/media/v4l2-core/videobuf2-dma-sg.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c b/drivers/media/v4l2-core/videobuf2-dma-sg.c
index 59522b2ebae1..16ae3dcc7e29 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-sg.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c
@@ -55,7 +55,8 @@ static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_fla
buf->write = 0;
buf->offset = 0;
buf->sg_desc.size = size;
- buf->sg_desc.num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
+ /* size is already page aligned */
+ buf->sg_desc.num_pages = size >> PAGE_SHIFT;
buf->sg_desc.sglist = vzalloc(buf->sg_desc.num_pages *
sizeof(*buf->sg_desc.sglist));