nor: fix memory leaks during probe
Fix similar memory leaks as per commit:
ef72484b78
Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
This commit is contained in:
parent
215353ef67
commit
86e851e1e2
|
@ -324,6 +324,12 @@ static int avrf_probe(struct flash_bank *bank)
|
|||
|
||||
if (avr_info != NULL)
|
||||
{
|
||||
if (bank->sectors)
|
||||
{
|
||||
free(bank->sectors);
|
||||
bank->sectors = NULL;
|
||||
}
|
||||
|
||||
// chip found
|
||||
bank->base = 0x00000000;
|
||||
bank->size = (avr_info->flash_page_size * avr_info->flash_page_num);
|
||||
|
|
|
@ -560,6 +560,12 @@ static int pic32mx_probe(struct flash_bank *bank)
|
|||
|
||||
LOG_INFO("flash size = %" PRId32 "kbytes", num_pages / 1024);
|
||||
|
||||
if (bank->sectors)
|
||||
{
|
||||
free(bank->sectors);
|
||||
bank->sectors = NULL;
|
||||
}
|
||||
|
||||
/* calculate numbers of pages */
|
||||
num_pages /= page_size;
|
||||
bank->size = (num_pages * page_size);
|
||||
|
|
|
@ -1065,6 +1065,12 @@ static int stellaris_probe(struct flash_bank *bank)
|
|||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
if (bank->sectors)
|
||||
{
|
||||
free(bank->sectors);
|
||||
bank->sectors = NULL;
|
||||
}
|
||||
|
||||
/* provide this for the benefit of the NOR flash framework */
|
||||
bank->size = 1024 * stellaris_info->num_pages;
|
||||
bank->num_sectors = stellaris_info->num_pages;
|
||||
|
|
|
@ -775,6 +775,12 @@ static int stm32x_probe(struct flash_bank *bank)
|
|||
/* calculate numbers of pages */
|
||||
num_pages /= (page_size / 1024);
|
||||
|
||||
if (bank->sectors)
|
||||
{
|
||||
free(bank->sectors);
|
||||
bank->sectors = NULL;
|
||||
}
|
||||
|
||||
bank->base = 0x08000000;
|
||||
bank->size = (num_pages * page_size);
|
||||
bank->num_sectors = num_pages;
|
||||
|
|
|
@ -139,6 +139,12 @@ static int tms470_read_part_info(struct flash_bank *bank)
|
|||
rom_flash = (device_ident_reg >> 10) & 1;
|
||||
part_number = (device_ident_reg >> 3) & 0x7f;
|
||||
|
||||
if (bank->sectors)
|
||||
{
|
||||
free(bank->sectors);
|
||||
bank->sectors = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the part number is known, determine if the flash bank is valid
|
||||
* based on the base address being within the known flash bank
|
||||
|
|
Loading…
Reference in New Issue