aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/uio
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-10-29 13:21:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-10-29 13:21:34 -0400
commit7314e613d5ff9f0934f7a0f74ed7973b903315d1 (patch)
tree71c58bf663e85fac4712ab86eaae78e889c41a49 /drivers/uio
parentf9ec2e6f7991e748e75e324ed05ca2a7ec360ebb (diff)
Fix a few incorrectly checked [io_]remap_pfn_range() calls
Nico Golde reports a few straggling uses of [io_]remap_pfn_range() that really should use the vm_iomap_memory() helper. This trivially converts two of them to the helper, and comments about why the third one really needs to continue to use remap_pfn_range(), and adds the missing size check. Reported-by: Nico Golde <nico@ngolde.de> Cc: stable@kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org.
Diffstat (limited to 'drivers/uio')
-rw-r--r--drivers/uio/uio.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index ba475632c5fa..0e808cf91d97 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -642,16 +642,29 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
642{ 642{
643 struct uio_device *idev = vma->vm_private_data; 643 struct uio_device *idev = vma->vm_private_data;
644 int mi = uio_find_mem_index(vma); 644 int mi = uio_find_mem_index(vma);
645 struct uio_mem *mem;
645 if (mi < 0) 646 if (mi < 0)
646 return -EINVAL; 647 return -EINVAL;
648 mem = idev->info->mem + mi;
647 649
648 vma->vm_ops = &uio_physical_vm_ops; 650 if (vma->vm_end - vma->vm_start > mem->size)
651 return -EINVAL;
649 652
653 vma->vm_ops = &uio_physical_vm_ops;
650 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 654 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
651 655
656 /*
657 * We cannot use the vm_iomap_memory() helper here,
658 * because vma->vm_pgoff is the map index we looked
659 * up above in uio_find_mem_index(), rather than an
660 * actual page offset into the mmap.
661 *
662 * So we just do the physical mmap without a page
663 * offset.
664 */
652 return remap_pfn_range(vma, 665 return remap_pfn_range(vma,
653 vma->vm_start, 666 vma->vm_start,
654 idev->info->mem[mi].addr >> PAGE_SHIFT, 667 mem->addr >> PAGE_SHIFT,
655 vma->vm_end - vma->vm_start, 668 vma->vm_end - vma->vm_start,
656 vma->vm_page_prot); 669 vma->vm_page_prot);
657} 670}