diff options
author | Ed Swierk <eswierk@aristanetworks.com> | 2008-11-03 17:41:16 -0500 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2008-11-03 17:41:16 -0500 |
commit | 88e7df0b7ee717f9db3333fb1248827bbdb2d4d3 (patch) | |
tree | c24dbb487be7f59869438974884f1aa86c48af19 /drivers | |
parent | f5dafca52d366ef8c6c86cbdfecc71a9a78b63a6 (diff) |
PCI: fix range check on mmapped sysfs resource files
pci_mmap_fits() returns the wrong answer if the sysfs resource file size
is not a multiple of the page size. vm_end and vm_start are already
page-aligned, so size - start < nr, causing mmap() to return EINVAL.
Signed-off-by: Ed Swierk <eswierk@aristanetworks.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pci/pci-sysfs.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 110022d78689..5d72866897a8 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -575,7 +575,7 @@ static int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct | |||
575 | 575 | ||
576 | nr = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; | 576 | nr = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; |
577 | start = vma->vm_pgoff; | 577 | start = vma->vm_pgoff; |
578 | size = pci_resource_len(pdev, resno) >> PAGE_SHIFT; | 578 | size = ((pci_resource_len(pdev, resno) - 1) >> PAGE_SHIFT) + 1; |
579 | if (start < size && size - start >= nr) | 579 | if (start < size && size - start >= nr) |
580 | return 1; | 580 | return 1; |
581 | WARN(1, "process \"%s\" tried to map 0x%08lx-0x%08lx on %s BAR %d (size 0x%08lx)\n", | 581 | WARN(1, "process \"%s\" tried to map 0x%08lx-0x%08lx on %s BAR %d (size 0x%08lx)\n", |