From patchwork Fri Mar 28 15:11:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 27306 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f69.google.com (mail-qg0-f69.google.com [209.85.192.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E6DBC20545 for ; Fri, 28 Mar 2014 15:13:58 +0000 (UTC) Received: by mail-qg0-f69.google.com with SMTP id a108sf5997349qge.4 for ; Fri, 28 Mar 2014 08:13:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:cc:subject :precedence:list-id:list-unsubscribe:list-post:list-help :list-subscribe:mime-version:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive :content-type:content-transfer-encoding; bh=8KxMD4LZVfHg2LfYT2Eo/3LmI5Ojlr4mpqNHZa6LB/0=; b=gg39cKEFPBOrZ92iHzoitpHA7+B70qZGtZJK01fJCou3dKfFX7WUUVwdKUbe9Jwnj4 pi+qF89K6EE4zPhIyDiWpIBr6QG9di1LmHQkvPhVatHRLEIB+224ylXBzEGy9Er8CCYM 7Cdjv5gh4QCpU3KhOFSQ95b1woy/DFV7++spxu1KI7F09W1IxVtnijWEF6IpmkVjbptD q5HfTLjeWAAcq/tXNG0HwSX7sAp4+u1c3O1xErAp4glLZewHouyPklkYxJG1lofn3hH9 2kdiFiovPFhZJ1MtpA59IOlP+2hre1M7TljAO51pV6ETUed65fsyEeZvtekCZe0kDxGI j5hA== X-Gm-Message-State: ALoCoQmrI/dkvxwTngNC7RZnZLeQ4AEBbfRtCg8+ATqP4ZtbSAo1REVQJx5WoL3GF/+MPn0e9LT1 X-Received: by 10.58.58.41 with SMTP id n9mr2046004veq.23.1396019638572; Fri, 28 Mar 2014 08:13:58 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.86.170 with SMTP id p39ls16202qgd.49.gmail; Fri, 28 Mar 2014 08:13:58 -0700 (PDT) X-Received: by 10.58.37.232 with SMTP id b8mr820234vek.27.1396019638501; Fri, 28 Mar 2014 08:13:58 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id ww7si1288019vec.156.2014.03.28.08.13.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Mar 2014 08:13:58 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id lg15so5986466vcb.16 for ; Fri, 28 Mar 2014 08:13:58 -0700 (PDT) X-Received: by 10.58.154.10 with SMTP id vk10mr7741700veb.18.1396019638409; Fri, 28 Mar 2014 08:13:58 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp16281vcv; Fri, 28 Mar 2014 08:13:58 -0700 (PDT) X-Received: by 10.140.104.103 with SMTP id z94mr2621960qge.91.1396019637701; Fri, 28 Mar 2014 08:13:57 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id c3si2677511qan.17.2014.03.28.08.13.57 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 28 Mar 2014 08:13:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WTYS4-0003SL-Po; Fri, 28 Mar 2014 15:12:12 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WTYS3-0003SA-6G for xen-devel@lists.xenproject.org; Fri, 28 Mar 2014 15:12:11 +0000 Received: from [85.158.143.35:9217] by server-3.bemta-4.messagelabs.com id 8C/A0-13602-A4195335; Fri, 28 Mar 2014 15:12:10 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-7.tower-21.messagelabs.com!1396019529!5459760!1 X-Originating-IP: [74.125.83.53] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.11.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9457 invoked from network); 28 Mar 2014 15:12:09 -0000 Received: from mail-ee0-f53.google.com (HELO mail-ee0-f53.google.com) (74.125.83.53) by server-7.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 28 Mar 2014 15:12:09 -0000 Received: by mail-ee0-f53.google.com with SMTP id b57so4177360eek.40 for ; Fri, 28 Mar 2014 08:12:09 -0700 (PDT) X-Received: by 10.15.81.135 with SMTP id x7mr2874346eey.61.1396019529513; Fri, 28 Mar 2014 08:12:09 -0700 (PDT) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id w12sm12172137eez.36.2014.03.28.08.12.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Mar 2014 08:12:08 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Fri, 28 Mar 2014 15:11:57 +0000 Message-Id: <1396019517-2778-1-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 Cc: stefano.stabellini@citrix.com, Keir Fraser , Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [PATCH v3] xen/serial: Don't leak memory mapping if the serial initialization has failed X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org 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.220.171 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 Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: The memory mapping leaked when the serial driver failed to retrieve the IRQ. We can safely move the call to ioremap after. Also use ioremap_cache instead of ioremap_attr in some serial drivers. Signed-off-by: Julien Grall Acked-by: Ian Campbell Cc: Keir Fraser Acked-by: Keir Fraser --- Changes in v3: - Fix typo in commit message Changes in v2: - s/ioremap_attr/ioremap_nocache - Move ioremap call after retrieve the IRQ --- xen/drivers/char/exynos4210-uart.c | 13 +++++++------ xen/drivers/char/omap-uart.c | 15 ++++++++------- xen/drivers/char/pl011.c | 15 +++++++-------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/xen/drivers/char/exynos4210-uart.c b/xen/drivers/char/exynos4210-uart.c index 0619575..150d49b 100644 --- a/xen/drivers/char/exynos4210-uart.c +++ b/xen/drivers/char/exynos4210-uart.c @@ -334,12 +334,6 @@ static int __init exynos4210_uart_init(struct dt_device_node *dev, return res; } - uart->regs = ioremap_nocache(addr, size); - if ( !uart->regs ) - { - early_printk("exynos4210: Unable to map the UART memory\n"); - return -ENOMEM; - } res = dt_device_get_irq(dev, 0, &uart->irq); if ( res ) { @@ -347,6 +341,13 @@ static int __init exynos4210_uart_init(struct dt_device_node *dev, return res; } + uart->regs = ioremap_nocache(addr, size); + if ( !uart->regs ) + { + early_printk("exynos4210: Unable to map the UART memory\n"); + return -ENOMEM; + } + uart->vuart.base_addr = addr; uart->vuart.size = size; uart->vuart.data_off = UTXH; diff --git a/xen/drivers/char/omap-uart.c b/xen/drivers/char/omap-uart.c index c1580ef..b29f610 100644 --- a/xen/drivers/char/omap-uart.c +++ b/xen/drivers/char/omap-uart.c @@ -326,13 +326,6 @@ static int __init omap_uart_init(struct dt_device_node *dev, return res; } - uart->regs = ioremap_attr(addr, size, PAGE_HYPERVISOR_NOCACHE); - if ( !uart->regs ) - { - early_printk("omap-uart: Unable to map the UART memory\n"); - return -ENOMEM; - } - res = dt_device_get_irq(dev, 0, &uart->irq); if ( res ) { @@ -340,6 +333,14 @@ static int __init omap_uart_init(struct dt_device_node *dev, return res; } + uart->regs = ioremap_nocache(addr, size); + if ( !uart->regs ) + { + early_printk("omap-uart: Unable to map the UART memory\n"); + return -ENOMEM; + } + + uart->vuart.base_addr = addr; uart->vuart.size = size; uart->vuart.data_off = UART_THR; diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c index fd82511..fe99af6 100644 --- a/xen/drivers/char/pl011.c +++ b/xen/drivers/char/pl011.c @@ -248,14 +248,6 @@ static int __init pl011_uart_init(struct dt_device_node *dev, return res; } - uart->regs = ioremap_attr(addr, size, PAGE_HYPERVISOR_NOCACHE); - if ( !uart->regs ) - { - early_printk("pl011: Unable to map the UART memory\n"); - - return -ENOMEM; - } - res = dt_device_get_irq(dev, 0, &uart->irq); if ( res ) { @@ -263,6 +255,13 @@ static int __init pl011_uart_init(struct dt_device_node *dev, return res; } + uart->regs = ioremap_nocache(addr, size); + if ( !uart->regs ) + { + early_printk("pl011: Unable to map the UART memory\n"); + return -ENOMEM; + } + uart->vuart.base_addr = addr; uart->vuart.size = size; uart->vuart.data_off = DR;