nor: fix memory leaks during probe
authorSpencer Oliver <ntfreak@users.sourceforge.net>
Sat, 29 May 2010 14:43:42 +0000 (15:43 +0100)
committerSpencer Oliver <ntfreak@users.sourceforge.net>
Sat, 29 May 2010 14:43:42 +0000 (15:43 +0100)
Fix similar memory leaks as per commit:
ef72484b785ec7462a0415afea679d08b864c7fb

Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
src/flash/nor/avrf.c
src/flash/nor/pic32mx.c
src/flash/nor/stellaris.c
src/flash/nor/stm32x.c
src/flash/nor/tms470.c

index 7cdab5193f70b2b55e94f5fb14e874050c62672a..8472d8362c00f5bb838559a89faa2ee512d809c1 100644 (file)
@@ -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);
index 58009ae57bf39259c12df8b5a8056c70008186ae..2fe864d4f0fbf592d05b76164e28a3ad1a7b6cc7 100644 (file)
@@ -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);
index 38374ffe50ad0ed3f61cd9639c01b9178d080fe4..f7e2e8d9df10079657a0ad36c070ee8fa5fe418b 100644 (file)
@@ -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;
index d11a8edc640b56c77b21965d92a7d70258029b30..8a3b83232c1d8806b5b3b8c4436b5a34bef76283 100644 (file)
@@ -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;
index c1681f1971ddc65f7be89be9e4e3b0fc6708bf80..343c43ed878f39557fa57b37c27b05dcc3a8096a 100644 (file)
@@ -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

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)