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>
This commit is contained in:
committed by
David Woodhouse
parent
dd8e9ed6ed
commit
25f0c659fe
@ -276,6 +276,7 @@ static int __init ppchameleonevb_init(void)
|
||||
/* Scan to find existence of the device (it could not be mounted) */
|
||||
if (nand_scan(ppchameleon_mtd, 1)) {
|
||||
iounmap((void *)ppchameleon_fio_base);
|
||||
ppchameleon_fio_base = NULL;
|
||||
kfree(ppchameleon_mtd);
|
||||
goto nand_evb_init;
|
||||
}
|
||||
@ -314,6 +315,8 @@ static int __init ppchameleonevb_init(void)
|
||||
ppchameleonevb_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
|
||||
if (!ppchameleonevb_mtd) {
|
||||
printk("Unable to allocate PPChameleonEVB NAND MTD device structure.\n");
|
||||
if (ppchameleon_fio_base)
|
||||
iounmap(ppchameleon_fio_base);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
@ -322,6 +325,8 @@ static int __init ppchameleonevb_init(void)
|
||||
if (!ppchameleonevb_fio_base) {
|
||||
printk("ioremap PPChameleonEVB NAND flash failed\n");
|
||||
kfree(ppchameleonevb_mtd);
|
||||
if (ppchameleon_fio_base)
|
||||
iounmap(ppchameleon_fio_base);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
@ -378,6 +383,8 @@ static int __init ppchameleonevb_init(void)
|
||||
if (nand_scan(ppchameleonevb_mtd, 1)) {
|
||||
iounmap((void *)ppchameleonevb_fio_base);
|
||||
kfree(ppchameleonevb_mtd);
|
||||
if (ppchameleon_fio_base)
|
||||
iounmap(ppchameleon_fio_base);
|
||||
return -ENXIO;
|
||||
}
|
||||
#ifdef CONFIG_MTD_PARTITIONS
|
||||
|
Reference in New Issue
Block a user