nor: fix memory leaks during probe
[fw/openocd] / src / flash / nor / tms470.c
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