diff options
author | Christian Eggers <ceggers@gmx.de> | 2014-02-01 10:17:17 +0100 |
---|---|---|
committer | Spencer Oliver <spen@spen-soft.co.uk> | 2014-03-04 20:13:58 +0000 |
commit | d36889e692788d4dc4acabd073d57f4a178e3172 (patch) | |
tree | dda4f27bdc4781a69a905195a68c6ef0ec4d5c7a /src/rtos/FreeRTOS.c | |
parent | bc1340cf0b9aa28c03d1b07c54b6e0bf4a483351 (diff) |
RTOS: Unify wipe-out of thread list
Each RTOS implementation uses it's own (similar) code to free
the thread list. There are some additional issues:
<--->
if (pointer != NULL)
free(pointer);
<--->
This is not necessary, free(NULL) is perfectly ok.
<--->
free(rtos->thread_details);
rtos->thread_details = NULL;
rtos->thread_count = 0;
<--->
The 3rd line has been missing for all RTOS but ChibiOs. There are paths
in the code where rtos->thread_count is never set to NULL, which can
lead to null pointer dereference of rtos->thread_details.
Change-Id: I6f7045c3d4518b925cb80dd5c907a566536b34ad
Signed-off-by: Christian Eggers <ceggers@gmx.de>
---
Changelog:
v7:
- rtos_wipe_threadlist() --> rtos_free_threadlist()
- removed non related changes in gdb_server.c from this patch
v3:
- Removed world "topic" from first line of commit message
v2:
- typo: "whipe" --> "wipe"
Reviewed-on: http://openocd.zylin.com/1916
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Diffstat (limited to 'src/rtos/FreeRTOS.c')
-rw-r--r-- | src/rtos/FreeRTOS.c | 20 |
1 files changed, 1 insertions, 19 deletions
diff --git a/src/rtos/FreeRTOS.c b/src/rtos/FreeRTOS.c index 321b1e12..598e2d66 100644 --- a/src/rtos/FreeRTOS.c +++ b/src/rtos/FreeRTOS.c @@ -173,25 +173,7 @@ static int FreeRTOS_update_threads(struct rtos *rtos) } /* wipe out previous thread details if any */ - if (rtos->thread_details != NULL) { - int j; - for (j = 0; j < rtos->thread_count; j++) { - if (rtos->thread_details[j].display_str != NULL) { - free(rtos->thread_details[j].display_str); - rtos->thread_details[j].display_str = NULL; - } - if (rtos->thread_details[j].thread_name_str != NULL) { - free(rtos->thread_details[j].thread_name_str); - rtos->thread_details[j].thread_name_str = NULL; - } - if (rtos->thread_details[j].extra_info_str != NULL) { - free(rtos->thread_details[j].extra_info_str); - rtos->thread_details[j].extra_info_str = NULL; - } - } - free(rtos->thread_details); - rtos->thread_details = NULL; - } + rtos_free_threadlist(rtos); /* read the current thread */ retval = target_read_buffer(rtos->target, |