]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] ioremap balanced with iounmap for drivers/serial/mpc52xx_uart.c
authorAmol Lad <amol@verismonetworks.com>
Sun, 1 Oct 2006 06:29:23 +0000 (23:29 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sun, 1 Oct 2006 07:39:32 +0000 (00:39 -0700)
ioremap must be balanced by an iounmap and failing to do so can result
in a memory leak.

Signed-off-by: Amol Lad <amol@verismonetworks.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/serial/mpc52xx_uart.c

index 7708e5dd3656967882ae990d1984e33b361301b3..dbad0e31e005864cb02c72b9f293ecbc11e906d5 100644 (file)
@@ -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