aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/maps/beech-mtd.c
diff options
context:
space:
mode:
authorAmol Lad <amol@verismonetworks.com>2006-09-21 18:12:43 +0530
committerDavid Woodhouse <dwmw2@infradead.org>2006-09-22 10:24:31 +0100
commit25f0c659fe64832d8ee06aa623fffaad708dcf8b (patch)
treeb5740156ac2ce5e39aaaba32ddb21b03379abb48 /drivers/mtd/maps/beech-mtd.c
parent[MTD] Switch to pci_get_device and do ref counting (diff)
downloadlinux-dev-25f0c659fe64832d8ee06aa623fffaad708dcf8b.tar.xz
linux-dev-25f0c659fe64832d8ee06aa623fffaad708dcf8b.zip
ioremap balanced with iounmap for drivers/mtd subsystem
ioremap must be balanced by an iounmap and failing to do so can result in a memory leak. Tested (compilation only) with: - allmodconfig - Modifying drivers/mtd/maps/Kconfig and drivers/mtd/nand/Kconfig to make sure that the changed file is compiling without warning Signed-off-by: Amol Lad <amol@verismonetworks.com> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'drivers/mtd/maps/beech-mtd.c')
-rw-r--r--drivers/mtd/maps/beech-mtd.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/mtd/maps/beech-mtd.c b/drivers/mtd/maps/beech-mtd.c
index 5df7361d1407..a64b1a5ab316 100644
--- a/drivers/mtd/maps/beech-mtd.c
+++ b/drivers/mtd/maps/beech-mtd.c
@@ -72,6 +72,8 @@ static struct mtd_partition beech_partitions[2] = {
static int __init
init_beech_mtd(void)
{
+ int err = 0;
+
printk("%s: 0x%08x at 0x%08x\n", NAME, SIZE, PADDR);
beech_mtd_map.virt = ioremap(PADDR, SIZE);
@@ -86,12 +88,20 @@ init_beech_mtd(void)
printk("%s: probing %d-bit flash bus\n", NAME, BUSWIDTH * 8);
beech_mtd = do_map_probe("cfi_probe", &beech_mtd_map);
- if (!beech_mtd)
+ if (!beech_mtd) {
+ iounmap((void *) beech_mtd_map.virt);
return -ENXIO;
+ }
beech_mtd->owner = THIS_MODULE;
- return add_mtd_partitions(beech_mtd, beech_partitions, 2);
+ err = add_mtd_partitions(beech_mtd, beech_partitions, 2);
+ if (err) {
+ printk("%s: add_mtd_partitions failed\n", NAME);
+ iounmap((void *) beech_mtd_map.virt);
+ }
+
+ return err;
}
static void __exit