target,flash: allow target_free_working_area on NULL area pointer
[openocd.git] / src / target / target.c
index ed6f655eac68607285030188b894db34141a4979..27888a83e1a153d8c7cef38635559bc0b5b734ca 100644 (file)
@@ -2148,11 +2148,10 @@ static int target_restore_working_area(struct target *target, struct working_are
 /* Restore the area's backup memory, if any, and return the area to the allocation pool */
 static int target_free_working_area_restore(struct target *target, struct working_area *area, int restore)
 {
-       int retval = ERROR_OK;
-
-       if (area->free)
-               return retval;
+       if (!area || area->free)
+               return ERROR_OK;
 
+       int retval = ERROR_OK;
        if (restore) {
                retval = target_restore_working_area(target, area);
                /* REVISIT: Perhaps the area should be freed even if restoring fails. */
@@ -6401,8 +6400,7 @@ next:
 out:
        free(test_pattern);
 
-       if (wa)
-               target_free_working_area(target, wa);
+       target_free_working_area(target, wa);
 
        /* Test writes */
        num_bytes = test_size + 4 + 4 + 4;
@@ -6486,8 +6484,7 @@ nextw:
 
        free(test_pattern);
 
-       if (wa)
-               target_free_working_area(target, wa);
+       target_free_working_area(target, wa);
        return retval;
 }
 

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)