aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/uio/uio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/uio/uio.c')
-rw-r--r--drivers/uio/uio.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 557e73ef5884..5dccf057a7dd 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -490,15 +490,23 @@ static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
490{ 490{
491 struct uio_device *idev = vma->vm_private_data; 491 struct uio_device *idev = vma->vm_private_data;
492 struct page *page; 492 struct page *page;
493 unsigned long offset;
493 494
494 int mi = uio_find_mem_index(vma); 495 int mi = uio_find_mem_index(vma);
495 if (mi < 0) 496 if (mi < 0)
496 return VM_FAULT_SIGBUS; 497 return VM_FAULT_SIGBUS;
497 498
499 /*
500 * We need to subtract mi because userspace uses offset = N*PAGE_SIZE
501 * to use mem[N].
502 */
503 offset = (vmf->pgoff - mi) << PAGE_SHIFT;
504
498 if (idev->info->mem[mi].memtype == UIO_MEM_LOGICAL) 505 if (idev->info->mem[mi].memtype == UIO_MEM_LOGICAL)
499 page = virt_to_page(idev->info->mem[mi].addr); 506 page = virt_to_page(idev->info->mem[mi].addr + offset);
500 else 507 else
501 page = vmalloc_to_page((void*)idev->info->mem[mi].addr); 508 page = vmalloc_to_page((void *)idev->info->mem[mi].addr
509 + offset);
502 get_page(page); 510 get_page(page);
503 vmf->page = page; 511 vmf->page = page;
504 return 0; 512 return 0;