[Xen-devel,for-4.5] xen/serial: Don't leak memory mapping if the serial initialization has failed

Message ID 1392154050-21649-1-git-send-email-julien.grall@linaro.org
State Superseded
Headers show

Commit Message

Julien Grall Feb. 11, 2014, 9:27 p.m.
Signed-off-by: Julien Grall <julien.grall@linaro.org>
---
 xen/drivers/char/exynos4210-uart.c |    1 +
 xen/drivers/char/omap-uart.c       |    1 +
 xen/drivers/char/pl011.c           |    1 +
 xen/include/asm-arm/mm.h           |    1 +
 4 files changed, 4 insertions(+)

Comments

Ian Campbell Feb. 19, 2014, 12:21 p.m. | #1
On Tue, 2014-02-11 at 21:27 +0000, Julien Grall wrote:
> Signed-off-by: Julien Grall <julien.grall@linaro.org>

Acked-by: Ian Campbell <ian.campbell@citrix.com>

Although you could also consider moving the dt_device_get_irq before the
ioremap_attr in most cases.
Julien Grall Feb. 19, 2014, 5:46 p.m. | #2
Hi Ian,

On 02/19/2014 12:21 PM, Ian Campbell wrote:
> On Tue, 2014-02-11 at 21:27 +0000, Julien Grall wrote:
>> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> 
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
> 
> Although you could also consider moving the dt_device_get_irq before the
> ioremap_attr in most cases.

I will use this solution.

Cheers,

Patch

diff --git a/xen/drivers/char/exynos4210-uart.c b/xen/drivers/char/exynos4210-uart.c
index 0619575..9a2b8b9 100644
--- a/xen/drivers/char/exynos4210-uart.c
+++ b/xen/drivers/char/exynos4210-uart.c
@@ -344,6 +344,7 @@  static int __init exynos4210_uart_init(struct dt_device_node *dev,
     if ( res )
     {
         early_printk("exynos4210: Unable to retrieve the IRQ\n");
+        iounmap(uart->regs);
         return res;
     }
 
diff --git a/xen/drivers/char/omap-uart.c b/xen/drivers/char/omap-uart.c
index c1580ef..bfc39b4 100644
--- a/xen/drivers/char/omap-uart.c
+++ b/xen/drivers/char/omap-uart.c
@@ -337,6 +337,7 @@  static int __init omap_uart_init(struct dt_device_node *dev,
     if ( res )
     {
         early_printk("omap-uart: Unable to retrieve the IRQ\n");
+        iounmap(uart->regs);
         return res;
     }
 
diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
index fd82511..f7be578 100644
--- a/xen/drivers/char/pl011.c
+++ b/xen/drivers/char/pl011.c
@@ -260,6 +260,7 @@  static int __init pl011_uart_init(struct dt_device_node *dev,
     if ( res )
     {
         early_printk("pl011: Unable to retrieve the IRQ\n");
+        iounmap(uart->regs);
         return res;
     }
 
diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h
index b8d4e7d..4211c0b 100644
--- a/xen/include/asm-arm/mm.h
+++ b/xen/include/asm-arm/mm.h
@@ -4,6 +4,7 @@ 
 #include <xen/config.h>
 #include <xen/kernel.h>
 #include <asm/page.h>
+#include <xen/vmap.h>
 #include <public/xen.h>
 
 /* Align Xen to a 2 MiB boundary. */