summaryrefslogtreecommitdiff
path: root/src/flash/nor
diff options
context:
space:
mode:
authorSpencer Oliver <ntfreak@users.sourceforge.net>2010-05-29 15:43:42 +0100
committerSpencer Oliver <ntfreak@users.sourceforge.net>2010-05-29 15:43:42 +0100
commit86e851e1e263c79f19eb9db52553de99f19b8bb9 (patch)
treef27ce597e5d63329677f4f5967beb0437350452d /src/flash/nor
parent215353ef67434e41b13f8948dc7dceefc110e3fe (diff)
downloadopenocd_libswd-86e851e1e263c79f19eb9db52553de99f19b8bb9.tar.gz
openocd_libswd-86e851e1e263c79f19eb9db52553de99f19b8bb9.tar.bz2
openocd_libswd-86e851e1e263c79f19eb9db52553de99f19b8bb9.tar.xz
openocd_libswd-86e851e1e263c79f19eb9db52553de99f19b8bb9.zip
nor: fix memory leaks during probe
Fix similar memory leaks as per commit: ef72484b785ec7462a0415afea679d08b864c7fb Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
Diffstat (limited to 'src/flash/nor')
-rw-r--r--src/flash/nor/avrf.c6
-rw-r--r--src/flash/nor/pic32mx.c6
-rw-r--r--src/flash/nor/stellaris.c6
-rw-r--r--src/flash/nor/stm32x.c6
-rw-r--r--src/flash/nor/tms470.c6
5 files changed, 30 insertions, 0 deletions
diff --git a/src/flash/nor/avrf.c b/src/flash/nor/avrf.c
index 7cdab519..8472d836 100644
--- a/src/flash/nor/avrf.c
+++ b/src/flash/nor/avrf.c
@@ -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);
diff --git a/src/flash/nor/pic32mx.c b/src/flash/nor/pic32mx.c
index 58009ae5..2fe864d4 100644
--- a/src/flash/nor/pic32mx.c
+++ b/src/flash/nor/pic32mx.c
@@ -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);
diff --git a/src/flash/nor/stellaris.c b/src/flash/nor/stellaris.c
index 38374ffe..f7e2e8d9 100644
--- a/src/flash/nor/stellaris.c
+++ b/src/flash/nor/stellaris.c
@@ -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;
diff --git a/src/flash/nor/stm32x.c b/src/flash/nor/stm32x.c
index d11a8edc..8a3b8323 100644
--- a/src/flash/nor/stm32x.c
+++ b/src/flash/nor/stm32x.c
@@ -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;
diff --git a/src/flash/nor/tms470.c b/src/flash/nor/tms470.c
index c1681f19..343c43ed 100644
--- a/src/flash/nor/tms470.c
+++ b/src/flash/nor/tms470.c
@@ -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