mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-10-04 18:40:42 +09:00
imx: nandbcb: Fix resource leak in read_fcb
Fix Coverity Issue 9006657. In read_fcb, leak of memory to system resource "fcb_raw_page". Adjust the sequence to check the mtd bad block prior than allocation of "fcb_raw_page", also check the NULL return of allocation. Signed-off-by: Ye Li <ye.li@nxp.com> Reviewed-by: Peng Fan <peng.fan@nxp.com> Signed-off-by: Peng Fan <peng.fan@nxp.com>
This commit is contained in:
parent
fc11dc112d
commit
f637c40dd7
@ -503,13 +503,18 @@ static int read_fcb(struct boot_config *boot_cfg, struct fcb_block *fcb,
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
mtd = boot_cfg->mtd;
|
mtd = boot_cfg->mtd;
|
||||||
fcb_raw_page = kzalloc(mtd->writesize + mtd->oobsize, GFP_KERNEL);
|
|
||||||
|
|
||||||
if (mtd_block_isbad(mtd, off)) {
|
if (mtd_block_isbad(mtd, off)) {
|
||||||
printf("Block %d is bad, skipped\n", (int)CONV_TO_BLOCKS(off));
|
printf("Block %d is bad, skipped\n", (int)CONV_TO_BLOCKS(off));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fcb_raw_page = kzalloc(mtd->writesize + mtd->oobsize, GFP_KERNEL);
|
||||||
|
if (!fcb_raw_page) {
|
||||||
|
debug("failed to allocate fcb_raw_page\n");
|
||||||
|
ret = -ENOMEM;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* User BCH hardware to decode ECC for FCB
|
* User BCH hardware to decode ECC for FCB
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user