diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-10-29 10:21:34 -0700 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2013-11-28 14:02:05 +0000 |
commit | 0bfd575845a118c5861ada86aba6211a5c1fc366 (patch) | |
tree | 8ae3451cda3c3820eea70099507fc2c463b46e2d /drivers/uio | |
parent | 0625072cc2e206b5fdf08db231c8cef99ac8c288 (diff) | |
download | kernel_samsung_smdk4412-0bfd575845a118c5861ada86aba6211a5c1fc366.zip kernel_samsung_smdk4412-0bfd575845a118c5861ada86aba6211a5c1fc366.tar.gz kernel_samsung_smdk4412-0bfd575845a118c5861ada86aba6211a5c1fc366.tar.bz2 |
Fix a few incorrectly checked [io_]remap_pfn_range() calls
commit 7314e613d5ff9f0934f7a0f74ed7973b903315d1 upstream.
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>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org.
[bwh: Backported to 3.2:
- Adjust context
- Also remove redundant vm_flags changes, removed separately upstream]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'drivers/uio')
-rw-r--r-- | drivers/uio/uio.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index a783d53..af57648 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -650,16 +650,28 @@ static int uio_mmap_physical(struct vm_area_struct *vma) { struct uio_device *idev = vma->vm_private_data; int mi = uio_find_mem_index(vma); + struct uio_mem *mem; if (mi < 0) return -EINVAL; + mem = idev->info->mem + mi; - vma->vm_flags |= VM_IO | VM_RESERVED; + if (vma->vm_end - vma->vm_start > mem->size) + return -EINVAL; vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + /* + * We cannot use the vm_iomap_memory() helper here, + * because vma->vm_pgoff is the map index we looked + * up above in uio_find_mem_index(), rather than an + * actual page offset into the mmap. + * + * So we just do the physical mmap without a page + * offset. + */ return remap_pfn_range(vma, vma->vm_start, - idev->info->mem[mi].addr >> PAGE_SHIFT, + mem->addr >> PAGE_SHIFT, vma->vm_end - vma->vm_start, vma->vm_page_prot); } |