Commit be618f550cb499db263e2ce22c5ad4f4dbfd53e6

Authored by Amol Lad
Committed by Linus Torvalds
1 parent 6257b3bdfd

[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 <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>

Showing 1 changed file with 10 additions and 1 deletions Side-by-side Diff

drivers/serial/mpc52xx_uart.c
... ... @@ -338,14 +338,23 @@
338 338 static int
339 339 mpc52xx_uart_request_port(struct uart_port *port)
340 340 {
  341 + int err;
  342 +
341 343 if (port->flags & UPF_IOREMAP) /* Need to remap ? */
342 344 port->membase = ioremap(port->mapbase, MPC52xx_PSC_SIZE);
343 345  
344 346 if (!port->membase)
345 347 return -EINVAL;
346 348  
347   - return request_mem_region(port->mapbase, MPC52xx_PSC_SIZE,
  349 + err = request_mem_region(port->mapbase, MPC52xx_PSC_SIZE,
348 350 "mpc52xx_psc_uart") != NULL ? 0 : -EBUSY;
  351 +
  352 + if (err && (port->flags & UPF_IOREMAP)) {
  353 + iounmap(port->membase);
  354 + port->membase = NULL;
  355 + }
  356 +
  357 + return err;
349 358 }
350 359  
351 360 static void