diff options
Diffstat (limited to 'drivers/uio')
-rw-r--r-- | drivers/uio/uio.c | 17 |
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 | } |