[PATCH] ioremap balanced with iounmap for drivers/serial/8250_acorn,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>
This commit is contained in:
parent
16c564bb3c
commit
f12ad7d59a
1 changed files with 5 additions and 4 deletions
|
@ -35,6 +35,7 @@ struct serial_card_type {
|
||||||
struct serial_card_info {
|
struct serial_card_info {
|
||||||
unsigned int num_ports;
|
unsigned int num_ports;
|
||||||
int ports[MAX_PORTS];
|
int ports[MAX_PORTS];
|
||||||
|
void __iomem *vaddr;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __devinit
|
static int __devinit
|
||||||
|
@ -44,7 +45,6 @@ serial_card_probe(struct expansion_card *ec, const struct ecard_id *id)
|
||||||
struct serial_card_type *type = id->data;
|
struct serial_card_type *type = id->data;
|
||||||
struct uart_port port;
|
struct uart_port port;
|
||||||
unsigned long bus_addr;
|
unsigned long bus_addr;
|
||||||
unsigned char __iomem *virt_addr;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
info = kmalloc(sizeof(struct serial_card_info), GFP_KERNEL);
|
info = kmalloc(sizeof(struct serial_card_info), GFP_KERNEL);
|
||||||
|
@ -55,8 +55,8 @@ serial_card_probe(struct expansion_card *ec, const struct ecard_id *id)
|
||||||
info->num_ports = type->num_ports;
|
info->num_ports = type->num_ports;
|
||||||
|
|
||||||
bus_addr = ecard_resource_start(ec, type->type);
|
bus_addr = ecard_resource_start(ec, type->type);
|
||||||
virt_addr = ioremap(bus_addr, ecard_resource_len(ec, type->type));
|
info->vaddr = ioremap(bus_addr, ecard_resource_len(ec, type->type));
|
||||||
if (!virt_addr) {
|
if (!info->vaddr) {
|
||||||
kfree(info);
|
kfree(info);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ serial_card_probe(struct expansion_card *ec, const struct ecard_id *id)
|
||||||
port.dev = &ec->dev;
|
port.dev = &ec->dev;
|
||||||
|
|
||||||
for (i = 0; i < info->num_ports; i ++) {
|
for (i = 0; i < info->num_ports; i ++) {
|
||||||
port.membase = virt_addr + type->offset[i];
|
port.membase = info->vaddr + type->offset[i];
|
||||||
port.mapbase = bus_addr + type->offset[i];
|
port.mapbase = bus_addr + type->offset[i];
|
||||||
|
|
||||||
info->ports[i] = serial8250_register_port(&port);
|
info->ports[i] = serial8250_register_port(&port);
|
||||||
|
@ -92,6 +92,7 @@ static void __devexit serial_card_remove(struct expansion_card *ec)
|
||||||
if (info->ports[i] > 0)
|
if (info->ports[i] > 0)
|
||||||
serial8250_unregister_port(info->ports[i]);
|
serial8250_unregister_port(info->ports[i]);
|
||||||
|
|
||||||
|
iounmap(info->vaddr);
|
||||||
kfree(info);
|
kfree(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue