target,flash: allow target_free_working_area on NULL area pointer
Standard C library free() allows NULL pointer as a parameter. Change target_free_working_area() to conform this convention. Remove NULL pointer tests before target_free_working_area() calls. While on it add missing setting pointer to NULL after target_free_working_area(). Change-Id: I7c692ab04a9933398ba5bc614723ad0bdecb87b3 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6712 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
committed by
Antonio Borneo
parent
35f284fe7c
commit
f735faa931
@@ -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)
|
||||
{
|
||||
if (!area || area->free)
|
||||
return ERROR_OK;
|
||||
|
||||
int retval = ERROR_OK;
|
||||
|
||||
if (area->free)
|
||||
return retval;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user