lkml.org 
[lkml]   [2017]   [Apr]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] cris: nand: fix a leak in error handling path
Date
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
\
 
 \ /
  Last update: 2017-04-30 09:19    [W:0.027 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site