From: Julien Grall <julien.grall@linaro.org>
To: xen-devel@lists.xenproject.org
Cc: stefano.stabellini@eu.citrix.com, tim@xen.org,
ian.campbell@citrix.com, Julien Grall <julien.grall@linaro.org>,
patches@linaro.org
Subject: [PATCH v2] xen/arm: ioremap_attr: return NULL is __vmap failed
Date: Mon, 18 Nov 2013 13:08:23 +0000 [thread overview]
Message-ID: <1384780103-10183-1-git-send-email-julien.grall@linaro.org> (raw)
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.
Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
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(-)
diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 26c6768..d5b22a4 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -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)
--
1.8.3.1
next reply other threads:[~2013-11-18 13:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-18 13:08 Julien Grall [this message]
2013-11-19 14:45 ` [PATCH v2] xen/arm: ioremap_attr: return NULL is __vmap failed Ian Campbell
2013-11-19 16:42 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1384780103-10183-1-git-send-email-julien.grall@linaro.org \
--to=julien.grall@linaro.org \
--cc=ian.campbell@citrix.com \
--cc=patches@linaro.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).