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