diff options
author | Tomas Vanek <vanekt@fbl.cz> | 2021-11-18 09:37:23 +0100 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2021-12-03 21:59:20 +0000 |
commit | f735faa9319af324b94e4257444419c8dfec6592 (patch) | |
tree | 1d42acd12cc96d37e19b278d17926c6f2e1e98c3 /src/flash/nor/cc26xx.c | |
parent | 35f284fe7c51d29768156cfec172152d2539d98a (diff) | |
download | riscv-openocd-f735faa9319af324b94e4257444419c8dfec6592.zip riscv-openocd-f735faa9319af324b94e4257444419c8dfec6592.tar.gz riscv-openocd-f735faa9319af324b94e4257444419c8dfec6592.tar.bz2 |
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>
Diffstat (limited to 'src/flash/nor/cc26xx.c')
-rw-r--r-- | src/flash/nor/cc26xx.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/flash/nor/cc26xx.c b/src/flash/nor/cc26xx.c index f6b5632..7e52649 100644 --- a/src/flash/nor/cc26xx.c +++ b/src/flash/nor/cc26xx.c @@ -140,8 +140,9 @@ static int cc26xx_init(struct flash_bank *bank) return retval; /* Check for working area to use for flash helper algorithm */ - if (cc26xx_bank->working_area) - target_free_working_area(target, cc26xx_bank->working_area); + target_free_working_area(target, cc26xx_bank->working_area); + cc26xx_bank->working_area = NULL; + retval = target_alloc_working_area(target, cc26xx_bank->algo_working_size, &cc26xx_bank->working_area); if (retval != ERROR_OK) @@ -158,6 +159,7 @@ static int cc26xx_init(struct flash_bank *bank) LOG_ERROR("%s: Failed to load flash helper algorithm", cc26xx_bank->family_name); target_free_working_area(target, cc26xx_bank->working_area); + cc26xx_bank->working_area = NULL; return retval; } @@ -172,6 +174,7 @@ static int cc26xx_init(struct flash_bank *bank) LOG_ERROR("%s: Failed to start flash helper algorithm", cc26xx_bank->family_name); target_free_working_area(target, cc26xx_bank->working_area); + cc26xx_bank->working_area = NULL; return retval; } |