From: Amol Lad Date: Sun, 1 Oct 2006 06:29:23 +0000 (-0700) Subject: [PATCH] ioremap balanced with iounmap for drivers/serial/mpc52xx_uart.c X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=be618f550cb499db263e2ce22c5ad4f4dbfd53e6;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git [PATCH] ioremap balanced with iounmap for drivers/serial/mpc52xx_uart.c ioremap must be balanced by an iounmap and failing to do so can result in a memory leak. Signed-off-by: Amol Lad Cc: Alan Cox Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c index 7708e5dd3656..dbad0e31e005 100644 --- a/drivers/serial/mpc52xx_uart.c +++ b/drivers/serial/mpc52xx_uart.c @@ -338,14 +338,23 @@ mpc52xx_uart_release_port(struct uart_port *port) static int mpc52xx_uart_request_port(struct uart_port *port) { + int err; + if (port->flags & UPF_IOREMAP) /* Need to remap ? */ port->membase = ioremap(port->mapbase, MPC52xx_PSC_SIZE); if (!port->membase) return -EINVAL; - return request_mem_region(port->mapbase, MPC52xx_PSC_SIZE, + err = request_mem_region(port->mapbase, MPC52xx_PSC_SIZE, "mpc52xx_psc_uart") != NULL ? 0 : -EBUSY; + + if (err && (port->flags & UPF_IOREMAP)) { + iounmap(port->membase); + port->membase = NULL; + } + + return err; } static void