Skip to contentSkip to conversation

xen/arm: ioremap_attr: return NULL is __vmap failed

PATCH In review Julien Grall 2 participants 3 messages Nov 18, 2013 – Nov 19, 2013

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xen/arm: ioremap_attr: return NULL is __vmap failed

Most of ioremap_* caller check if ioremap returns NULL. Actually, if the physical address is non-aligned, Xen will return the pointer given by __vmap plus the offset in the page. So if ioremap_* fails, the caller will retrieve an non-NULL address and continue as if there was no error.

---
Changes in v2:
- remove brackets for return
- don't split declaration and initialisation of ptr

---
 xen/arch/arm/mm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
xen/arch/arm/mm.c +5 -1
index 26c6768..d5b22a4 100644
@@ -742,8 +742,12 @@ void *ioremap_attr(paddr_t pa, size_t len, unsigned int attributes)
     unsigned long pfn = PFN_DOWN(pa);
     unsigned int offs = pa & (PAGE_SIZE - 1);
     unsigned int nr = PFN_UP(offs + len);
+    void *ptr = __vmap(&pfn, nr, 1, 1, attributes);
 
-    return (__vmap(&pfn, nr, 1, 1, attributes) + offs);
+    if ( ptr == NULL )
+        return NULL;
+
+    return ptr + offs;
 }
 
 void *ioremap(paddr_t pa, size_t len)
Signature · 1 line
1.8.3.1
Acked-by on v2 1/1
#1 lore raw
Quoted 7 lines · Julien Grall

Most of ioremap_* caller check if ioremap returns NULL. Actually, if the physical address is non-aligned, Xen will return the pointer given by __vmap plus the offset in the page. So if ioremap_* fails, the caller will retrieve an non-NULL address and continue as if there was no error.

#2 lore raw
Quoted 10 lines · Ian Campbell
Quoted 7 lines · Julien Grall

Most of ioremap_* caller check if ioremap returns NULL. Actually, if the physical address is non-aligned, Xen will return the pointer given by __vmap plus the offset in the page. So if ioremap_* fails, the caller will retrieve an non-NULL address and continue as if there was no error.

Applied this +
xen/arm: Panic if platform initialization failed xen/arm: Panic if we are unable to initialize platform timer

from the first posting.