From patchwork Mon Nov 18 13:08:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 21580 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f70.google.com (mail-pb0-f70.google.com [209.85.160.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 10495202DA for ; Mon, 18 Nov 2013 13:08:31 +0000 (UTC) Received: by mail-pb0-f70.google.com with SMTP id rq2sf413899pbb.1 for ; Mon, 18 Nov 2013 05:08:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=pS3j4gYMHwG/J7/Y/yQPWhXGfI74EOi1XXk7zaix4ms=; b=FLD4W8swvNJYpk/Eo50V3hMKE4Cb+oDWN3tpLIXFia57HC8b9D7C6rGWoZ0l6HxCbG WJC/hlzlSIluqoSLfdTFjlbjrle/Lby8TLrB45rUQBKNytasDTXTNMuRaIAUuQihcCEr I4Po18xFcaXl78GOnWftP83CE4YQ1swB/NiIoHmLi+fji2QmkSXw7EGOqajCTZ7Aj/Ug +HQmqKwE5M8e7saQQ3NWdssgjESrl33oQHrKz7Ju1z66gX23bst69RbjxPGCCbZXyEeW uYnWe2QflOAmiV0FIR0ldMmKWZ79qz6JLX2wAOlxouqamnqgLaJgJqLGI/BN0Jm6wJI0 QG9g== X-Gm-Message-State: ALoCoQkXt2SemrpUtxi86w8bd1d7AYYsky/AvC9gS7TJQY9o0XReAMc62/ydBscUgFogGyCgik1X X-Received: by 10.66.102.69 with SMTP id fm5mr8211728pab.24.1384780110859; Mon, 18 Nov 2013 05:08:30 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.81.229 with SMTP id d5ls271918qey.64.gmail; Mon, 18 Nov 2013 05:08:30 -0800 (PST) X-Received: by 10.58.233.98 with SMTP id tv2mr15628663vec.11.1384780110687; Mon, 18 Nov 2013 05:08:30 -0800 (PST) Received: from mail-vb0-f49.google.com (mail-vb0-f49.google.com [209.85.212.49]) by mx.google.com with ESMTPS id k10si7207485vca.49.2013.11.18.05.08.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 18 Nov 2013 05:08:30 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.49 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.49; Received: by mail-vb0-f49.google.com with SMTP id o19so4540073vbm.22 for ; Mon, 18 Nov 2013 05:08:30 -0800 (PST) X-Received: by 10.220.74.69 with SMTP id t5mr15706137vcj.18.1384780110572; Mon, 18 Nov 2013 05:08:30 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp200430vcz; Mon, 18 Nov 2013 05:08:30 -0800 (PST) X-Received: by 10.194.11.67 with SMTP id o3mr17313548wjb.0.1384780109244; Mon, 18 Nov 2013 05:08:29 -0800 (PST) Received: from mail-wg0-f51.google.com (mail-wg0-f51.google.com [74.125.82.51]) by mx.google.com with ESMTPS id bi9si6132355wjc.121.2013.11.18.05.08.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 18 Nov 2013 05:08:29 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.51 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.82.51; Received: by mail-wg0-f51.google.com with SMTP id m15so6213556wgh.30 for ; Mon, 18 Nov 2013 05:08:28 -0800 (PST) X-Received: by 10.180.89.98 with SMTP id bn2mr16854232wib.63.1384780108809; Mon, 18 Nov 2013 05:08:28 -0800 (PST) Received: from localhost.localdomain (cpc8-cmbg15-2-0-cust169.5-4.cable.virginm.net. [86.30.140.170]) by mx.google.com with ESMTPSA id pi6sm24007564wic.3.2013.11.18.05.08.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Nov 2013 05:08:28 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Cc: ian.campbell@citrix.com, tim@xen.org, patches@linaro.org, stefano.stabellini@eu.citrix.com, Julien Grall Subject: [PATCH v2] xen/arm: ioremap_attr: return NULL is __vmap failed Date: Mon, 18 Nov 2013 13:08:23 +0000 Message-Id: <1384780103-10183-1-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.8.3.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.49 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 Acked-by: Stefano Stabellini Acked-by: Ian Campbell --- 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)