[PATCH 7/9] NAND: imx: Fix memory leak
Alexander Shiyan
shc_work at mail.ru
Fri Apr 26 12:41:12 EDT 2013
Signed-off-by: Alexander Shiyan <shc_work at mail.ru>
---
drivers/mtd/nand/nand_imx_bbm.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/nand/nand_imx_bbm.c b/drivers/mtd/nand/nand_imx_bbm.c
index 03961a0..135d74e 100644
--- a/drivers/mtd/nand/nand_imx_bbm.c
+++ b/drivers/mtd/nand/nand_imx_bbm.c
@@ -91,7 +91,7 @@ static void *create_bbt(struct mtd_info *mtd)
buf = malloc(mtd->writesize);
if (!buf) {
ret = -ENOMEM;
- goto out;
+ goto out2;
}
numblocks = mtd->size >> (chip->bbt_erase_shift - 1);
@@ -99,7 +99,7 @@ static void *create_bbt(struct mtd_info *mtd)
for (i = 0; i < numblocks;) {
ret = checkbad(mtd, from, buf);
if (ret < 0)
- goto out;
+ goto out1;
if (ret) {
bbt[i >> 3] |= 0x03 << (i & 0x6);
@@ -112,8 +112,11 @@ static void *create_bbt(struct mtd_info *mtd)
}
return bbt;
-out:
+
+out1:
free(buf);
+out2:
+ free(bbt);
return ERR_PTR(ret);
}
--
1.8.1.5
More information about the barebox
mailing list