summaryrefslogtreecommitdiffstats
path: root/drivers/uio
diff options
context:
space:
mode:
authorHillf Danton <dhillf@gmail.com>2011-03-28 23:33:26 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2011-04-19 16:56:02 -0700
commitf0c554fddd3be561542cd37acdb3adc9ec5483ee (patch)
treeebd4e07dbce73eec19a4161307a1793e65eb82d8 /drivers/uio
parentd8408aef910b5d538ae07218992b270a9e01067f (diff)
downloadlinux-f0c554fddd3be561542cd37acdb3adc9ec5483ee.tar.gz
linux-f0c554fddd3be561542cd37acdb3adc9ec5483ee.tar.bz2
linux-f0c554fddd3be561542cd37acdb3adc9ec5483ee.zip
uio: fix finding mm index for vma
When finding mm index for vma it looks more flexible that the mm could be sparse, and both the size of mm and the pgoff of vma could give correct selection. Signed-off-by: Hillf Danton <dhillf@gmail.com> Signed-off-by: Hans J. Koch <hjk@hansjkoch.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/uio')
-rw-r--r--drivers/uio/uio.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 51fe1795d5a8..10a029b24159 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -587,14 +587,12 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
static int uio_find_mem_index(struct vm_area_struct *vma)
{
- int mi;
struct uio_device *idev = vma->vm_private_data;
- for (mi = 0; mi < MAX_UIO_MAPS; mi++) {
- if (idev->info->mem[mi].size == 0)
+ if (vma->vm_pgoff < MAX_UIO_MAPS) {
+ if (idev->info->mem[vma->vm_pgoff].size == 0)
return -1;
- if (vma->vm_pgoff == mi)
- return mi;
+ return (int)vma->vm_pgoff;
}
return -1;
}