From: Hillf Danton Date: Mon, 28 Mar 2011 21:33:26 +0000 (+0200) Subject: uio: fix finding mm index for vma X-Git-Tag: upstream/snapshot3+hdmi~10399^2~35 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f0c554fddd3be561542cd37acdb3adc9ec5483ee;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git 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 Signed-off-by: Hans J. Koch Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 51fe179..10a029b 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; }