]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/xen.git/commitdiff
xen/serial: Don't leak memory mapping if the serial initialization has failed
authorJulien Grall <julien.grall@linaro.org>
Fri, 28 Mar 2014 15:11:57 +0000 (15:11 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 1 Apr 2014 10:26:55 +0000 (11:26 +0100)
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 <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
xen/drivers/char/exynos4210-uart.c
xen/drivers/char/omap-uart.c
xen/drivers/char/pl011.c

index 061957560cfd2170d7f685a31811f93fb55ba1bd..150d49bb6aa1bf9b259344d91b2d9f4cdd01a732 100644 (file)
@@ -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;
index c1580ef294b91f51cc72683b9a5a1099a71872c8..b29f6102d35fe7a65862e3b796d42ddd67c489cf 100644 (file)
@@ -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;
index fd82511bf98f2cc8c2c8751b2a8211cac2d92e84..fe99af6881ebf269274dd764ccd4075354102097 100644 (file)
@@ -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;