xen/serial: Don't leak memory mapping if the serial initialization has failed
PATCH v3 1/1 xen/serial: Don't leak memory mapping if the serial initialization has failed
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.
---
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(-)
xen/drivers/char/exynos4210-uart.c +7 -6
@@ -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 ;
xen/drivers/char/omap-uart.c +8 -7
@@ -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 ;
xen/drivers/char/pl011.c +7 -8
@@ -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 ;
Signature · 1 line
1.7.10.4
Quoted 8 lines · Julien Grall
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_cacheinstead ofioremap_attrin some serial drivers.Signed-off-by Julien Grall<[email protected]>Acked-by Ian Campbell<[email protected]>Cc Keir Fraser<[email protected]>
Ian Campbell
AppliedQuoted 10 lines · Keir Fraser
Quoted 8 lines · Julien Grall
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_cacheinstead ofioremap_attrin some serial drivers.Signed-off-by Julien Grall<[email protected]>Acked-by Ian Campbell<[email protected]>Cc Keir Fraser<[email protected]>Acked-by Keir Fraser <[email protected]>
Applied, thanks.
Ian.