Skip to content

Commit

Permalink
[PATCH] ioremap balanced with iounmap for drivers/serial/mpc52xx_uart.c
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Amol Lad authored and Linus Torvalds committed Oct 1, 2006
1 parent 6257b3b commit be618f5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion drivers/serial/mpc52xx_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit be618f5

Please sign in to comment.