[PATCH] cris: nand: fix a leak in error handling path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If only 1 of the 2 'ioremap' fails, then there is a small leak.

Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
 arch/cris/arch-v32/drivers/mach-fs/nandflash.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
index a74540514bdb..57622fbd9f25 100644
--- a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
+++ b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
@@ -123,7 +123,7 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
 	if (!read_cs || !write_cs) {
 		printk(KERN_ERR "CRISv32 NAND ioremap failed\n");
 		err = -EIO;
-		goto out_mtd;
+		goto out_ior;
 	}
 
 	/* Get pointer to private data */
@@ -162,9 +162,11 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
 	return crisv32_mtd;
 
 out_ior:
-	iounmap((void *)read_cs);
-	iounmap((void *)write_cs);
-out_mtd:
+	if (read_cs)
+		iounmap((void *)read_cs);
+	if (write_cs)
+		iounmap((void *)write_cs);
+
 	kfree(wrapper);
 	return NULL;
 }
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux