Skip to content

Commit

Permalink
uio: fix finding mm index for vma
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Hillf Danton authored and Greg Kroah-Hartman committed Apr 19, 2011
1 parent d8408ae commit f0c554f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions drivers/uio/uio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit f0c554f

Please sign in to comment.