9
0
Fork 0

NAND: imx: Fix memory leak

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Alexander Shiyan 2013-04-26 20:41:12 +04:00 committed by Sascha Hauer
parent 32d531574f
commit 7c15fd1b09
1 changed files with 6 additions and 3 deletions

View File

@ -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);
}