summaryrefslogtreecommitdiffstats
path: root/drivers/media/v4l2-core/videobuf-dma-contig.c
diff options
context:
space:
mode:
authorAndrew F. Davis <afd@ti.com>2019-03-29 13:34:27 -0400
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2019-05-29 13:07:56 -0400
commit835706214875de6e6f8b9d01ceeed17b20622677 (patch)
treeb560188e1daf6287030afb5b84008f7a464c3794 /drivers/media/v4l2-core/videobuf-dma-contig.c
parent6211e44a4dfc2a12c5d40984ab876537bf0d0830 (diff)
downloadlinux-835706214875de6e6f8b9d01ceeed17b20622677.tar.bz2
media: videobuf-dma-contig: Use size of buffer in mmap not vma size
The size of the vma can be larger than the size of the backing buffer. Use the buffer size over vma size to prevent exposing extra memory to userspace. Signed-off-by: Andrew F. Davis <afd@ti.com> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/v4l2-core/videobuf-dma-contig.c')
-rw-r--r--drivers/media/v4l2-core/videobuf-dma-contig.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/media/v4l2-core/videobuf-dma-contig.c b/drivers/media/v4l2-core/videobuf-dma-contig.c
index e1bf50df4c70..65e2655d22b7 100644
--- a/drivers/media/v4l2-core/videobuf-dma-contig.c
+++ b/drivers/media/v4l2-core/videobuf-dma-contig.c
@@ -280,7 +280,6 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q,
struct videobuf_dma_contig_memory *mem;
struct videobuf_mapping *map;
int retval;
- unsigned long size;
dev_dbg(q->dev, "%s\n", __func__);
@@ -303,7 +302,6 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q,
goto error;
/* Try to remap memory */
- size = vma->vm_end - vma->vm_start;
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
/* the "vm_pgoff" is just used in v4l2 to find the
@@ -314,7 +312,7 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q,
*/
vma->vm_pgoff = 0;
- retval = vm_iomap_memory(vma, mem->dma_handle, size);
+ retval = vm_iomap_memory(vma, mem->dma_handle, mem->size);
if (retval) {
dev_err(q->dev, "mmap: remap failed with error %d. ",
retval);