xen/serial: Don't leak memory mapping if the serial initialization has failed
PATCH v2 1/1 xen/serial: Don't leak memory mapping if the serial initialization has failed
The memory mapping is leaking 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.
---
Ian, I have dropped your ack because the patch fundamentaly changed.
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
Ping?
Quoted 118 lines · Julien Grall
The memory mapping is leaking 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]>---
Ian, I have dropped your ack because the patch fundamentaly changed.
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
Julien Grall
Quoted 2 lines
Quoted 1 line
Quoted 1 line · Julien Grall
Ping?
I'm afraid this will lead no-where if you don't include Keir on at least the Cc list. (Of course these are all ARM-only drivers, so getting an ARM maintainer's ack or an ARM maintainer to commit this might also be acceptable, by slightly bending the policy.)
Jan
Quoted 135 lines · Julien Grall
Quoted 14 lines
The memory mapping is leaking 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]>---
Ian, I have dropped your ack because the patch fundamentaly changed.
Changes in v2:
- s/ioremap_attr/ioremap_nocache
- Move ioremap call after retrieve the IRQReview
Quoted 7 lines
--- 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(-)(quoted diff) +0
-0
b/xen/drivers/char/exynos4210-uart.cxen/drivers/char/exynos4210-uart.c static int __init exynos4210_uart_init(struct
Quoted 4 lines
index 0619575..150d49b 100644
xen/drivers/char/exynos4210-uart.c +0
-0@@ -334,12 +334,6 @@ static int __init exynos4210_uart_init(struct
dt_device_node*dev,xen/drivers/char/exynos4210-uart.c static int __init exynos4210_uart_init(struct
Quoted 13 lines
xen/drivers/char/exynos4210-uart.c +0
-6return 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,xen/drivers/char/omap-uart.c static int __init omap_uart_init(struct dt_device_node
Quoted 18 lines
xen/drivers/char/exynos4210-uart.c +7
-0return 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 +0
-0@@ -326,13 +326,6 @@ static int __init omap_uart_init(struct dt_device_node*dev,
xen/drivers/char/omap-uart.c static int __init omap_uart_init(struct dt_device_node
Quoted 14 lines
xen/drivers/char/omap-uart.c +0
-7return 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,
xen/drivers/char/pl011.c static int __init pl011_uart_init(struct dt_device_node
Quoted 19 lines
xen/drivers/char/omap-uart.c +8
-0return 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 +0
-0@@ -248,14 +248,6 @@ static int __init pl011_uart_init(struct dt_device_node*dev,
xen/drivers/char/pl011.c static int __init pl011_uart_init(struct dt_device_node
Quoted 15 lines
xen/drivers/char/pl011.c +0
-8return 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,
Quoted 14 lines
xen/drivers/char/pl011.c +7
-0return 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 · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 7 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · Julien Grall
Ping?
I'm afraid this will lead no-where if you don't include Keir on at least the Cc list. (Of course these are all ARM-only drivers, so getting an ARM maintainer's ack or an ARM maintainer to commit this might also be acceptable, by slightly bending the policy.)
Hmmm ... right (adding Keir). I have noticed that every changes on ARM-only drivers were not acked by Keir.
I'm wondering if we can move ARM-only serial drivers under ARM maintainer section.
Signature · 1 line
Julien Grall
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Julien Grall
Quoted 7 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · Julien Grall
Ping?
I'm afraid this will lead no-where if you don't include Keir on at least the Cc list. (Of course these are all ARM-only drivers, so getting an ARM maintainer's ack or an ARM maintainer to commit this might also be acceptable, by slightly bending the policy.)
Quoted 5 lines
Hmmm ... right (adding Keir). I have noticed that every changes on ARM-only drivers were not acked by Keir.
I'm wondering if we can move ARM-only serial drivers under ARM maintainer section.
I wouldn't mind.
Jan
Quoted 10 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Julien Grall
Quoted 7 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · Julien Grall
Ping?
I'm afraid this will lead no-where if you don't include Keir on at least the Cc list. (Of course these are all ARM-only drivers, so getting an ARM maintainer's ack or an ARM maintainer to commit this might also be acceptable, by slightly bending the policy.)
Quoted 7 lines
Quoted 5 lines
Hmmm ... right (adding Keir). I have noticed that every changes on ARM-only drivers were not acked by Keir.
I'm wondering if we can move ARM-only serial drivers under ARM maintainer section.
I wouldn't mind.
It makes sense to me too. Julien, can you make patch to MAINTAINERS please. Don't forget to CC Keir that one last time ;-)
Ian.
Ian, Keir: Ping?
Quoted 118 lines · Julien Grall
The memory mapping is leaking 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]>---
Ian, I have dropped your ack because the patch fundamentaly changed.
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
Julien Grall
Quoted 1 line · Julien Grall
The memory mapping is leaking when the serial driver failed to retrieve
"leaked"
Quoted 9 lines
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]>---
Ian, I have dropped your ack because the patch fundamentaly changed.
Apart from the grammar nit you can reinstate it now, I've rereviewed.
You didn't CC Keir BTW.