Skip to content

Commit f0c554f

Browse files
Hillf Dantongregkh
authored andcommitted
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>
1 parent d8408ae commit f0c554f

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

‎drivers/uio/uio.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -587,14 +587,12 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
587587

588588
static int uio_find_mem_index(struct vm_area_struct *vma)
589589
{
590-
int mi;
591590
struct uio_device *idev = vma->vm_private_data;
592591

593-
for (mi = 0; mi < MAX_UIO_MAPS; mi++) {
594-
if (idev->info->mem[mi].size == 0)
592+
if (vma->vm_pgoff < MAX_UIO_MAPS) {
593+
if (idev->info->mem[vma->vm_pgoff].size == 0)
595594
return -1;
596-
if (vma->vm_pgoff == mi)
597-
return mi;
595+
return (int)vma->vm_pgoff;
598596
}
599597
return -1;
600598
}

0 commit comments

Comments
 (0)