Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1633399

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

From Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Newsgroups linux.kernel
Subject [PATCH] cris: nand: fix a leak in error handling path
Date 2017-04-30 09:20 +0200
Message-ID <tBRjb-fm-3@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 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

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] cris: nand: fix a leak in error handling path Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-04-30 09:20 +0200

csiph-web