Bug fixes for reserve_memtype() call in __ioremap and pci_mmap_page_range().
If reserve_memtype returns non-zero, then it is an error and subsequent free is
not required. Requested and returned prot value check should be done when
reserve_memtype returns success.
Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
arch/x86/mm/ioremap.c | 11 +++++++++--
arch/x86/pci/i386.c | 7 ++++++-
2 files changed, 15 insertions(+), 3 deletions(-)
Index: linux-2.6-x86.git/arch/x86/mm/ioremap.c
===================================================================
--- linux-2.6-x86.git.orig/arch/x86/mm/ioremap.c 2008-03-21 08:28:47.000000000 -0700
+++ linux-2.6-x86.git/arch/x86/mm/ioremap.c 2008-03-24 06:59:09.000000000 -0700
@@ -126,6 +126,7 @@ static void __iomem *__ioremap(unsigned
unsigned long new_prot_val;
pgprot_t prot;
void __iomem *ret_addr;
+ int retval;
/* Don't allow wraparound or zero size */
last_addr = phys_addr + size - 1;
@@ -165,8 +166,14 @@ static void __iomem *__ioremap(unsigned
phys_addr &= PAGE_MASK;
size = PAGE_ALIGN(last_addr+1) - phys_addr;
- if (reserve_memtype(phys_addr, phys_addr + size,
- prot_val, &new_prot_val)) {
+ retval = reserve_memtype(phys_addr, phys_addr + size,
+ prot_val, &new_prot_val);
+ if (retval) {
+ printk("reserve_memtype returned %d\n", retval);
+ return NULL;
+ }
+
+ if (prot_val != new_prot_val) {
/*
* Do not fallback to certain memory types with certain
* requested type:
Index: linux-2.6-x86.git/arch/x86/pci/i386.c
===================================================================
--- linux-2.6-x86.git.orig/arch/x86/pci/i386.c 2008-03-21 08:28:47.000000000 -0700
+++ linux-2.6-x86.git/arch/x86/pci/i386.c 2008-03-24 07:01:22.000000000 -0700
@@ -328,6 +328,7 @@ int pci_mmap_page_range(struct pci_dev *
unsigned long len = vma->vm_end - vma->vm_start;
unsigned long flags;
unsigned long new_flags;
+ int retval;
/* I/O space cannot be accessed via normal processor loads and
* stores on this platform.
@@ -344,7 +345,11 @@ int pci_mmap_page_range(struct pci_dev *
vma->vm_page_prot = __pgprot(prot);
flags = pgprot_val(vma->vm_page_prot) & _PAGE_CACHE_MASK;
- if (reserve_memtype(addr, addr + len, flags, &new_flags)) {
+ retval = reserve_memtype(addr, addr + len, flags, &new_flags);
+ if (retval)
+ return retval;
+
+ if (flags != new_flags) {
/*
* Do not fallback to certain memory types with certain
* requested type:
--
| Artem Bityutskiy | [PATCH 10/44 take 2] [UBI] debug unit implementation |
| Jeremy Fitzhardinge | [PATCH 03 of 36] x86: add memory barriers to wrmsr |
| Zachary Amsden | Re: [patch 13/26] Xen-paravirt_ops: Consistently wrap paravirt ops callsites to ma... |
| Justin Mattock | macbook pro dvd playback after suspend Buffer I/O error |
git: | |
| David Kastrup | Empty directories... |
| Johannes Schindelin | Re: [PATCH 1/4] Move redo merge code in a function |
| Jeff King | Re: detecting rename->commit->modify->commit |
| Pierre Habouzit | Re: [RFC] git integrated bugtracking |
| David Higgs | Re: Using the C programming language |
| Chris Bullock | OpenBSD isakmpd and pf vs Cisco PIX or ASA |
| Richard Stallman | Real men don't attack straw men |
| Chris S | Re: No text cursor on OpenBSD/i386 4.1 |
| Jojie R. T. | Re: SLS |
| Peter MacDonald | demand paging: proposal |
| Theodore Ts'o | Re: Stabilizing Linux |
| Doug Evans | Re: Stabilizing Linux |
| Battery Maximizer Software | 9 hours ago | Linux kernel |
| windows folder creation surprise | 10 hours ago | Windows |
| Problem in scim in Fedora 9 | 11 hours ago | Linux general |
| Firewall | 1 day ago | OpenBSD |
| IP layer send packet | 1 day ago | Linux kernel |
| dtrace for linux available | 2 days ago | Linux kernel |
| Unable to mount ramdisk image using UBoot while upgrading to 2.6.15 kernel for a MPC8540 based target | 2 days ago | Linux kernel |
| RealTek RTL8169 - can't connect | 2 days ago | NetBSD |
| vsftpd Upload Problems | 2 days ago | Linux general |
| creating con folder in desktop | 3 days ago | Windows |
