X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Frtos%2FFreeRTOS.c;h=1e4ddc532a51c1c68d905f66548d61f122df718b;hp=2c4791745b3b9aba607eb2bd918b8a20d6116210;hb=60a932b36804bff8b6ca40adc665a33a59475db1;hpb=fe11baeebb4e238d4bdc47382edb68d3b4156fd3 diff --git a/src/rtos/FreeRTOS.c b/src/rtos/FreeRTOS.c index 2c4791745b..1e4ddc532a 100644 --- a/src/rtos/FreeRTOS.c +++ b/src/rtos/FreeRTOS.c @@ -30,6 +30,8 @@ #include "helper/log.h" #include "rtos_standard_stackings.h" +#define FREERTOS_MAX_PRIORITIES 63 + #define FreeRTOS_STRUCT(int_type, ptr_type, list_prev_offset) struct FreeRTOS_params { @@ -220,6 +222,11 @@ static int FreeRTOS_update_threads(struct rtos *rtos) (uint8_t *)&max_used_priority); if (retval != ERROR_OK) return retval; + if (max_used_priority > FREERTOS_MAX_PRIORITIES) { + LOG_ERROR("FreeRTOS maximum used priority is unreasonably big, not proceeding: %" PRId64 "", + max_used_priority); + return ERROR_FAIL; + } symbol_address_t *list_of_lists = (symbol_address_t *)malloc(sizeof(symbol_address_t) * @@ -252,6 +259,7 @@ static int FreeRTOS_update_threads(struct rtos *rtos) (uint8_t *)&list_thread_count); if (retval != ERROR_OK) { LOG_OUTPUT("Error reading number of threads in FreeRTOS thread list\r\n"); + free(list_of_lists); return retval; } @@ -266,8 +274,8 @@ static int FreeRTOS_update_threads(struct rtos *rtos) param->pointer_width, (uint8_t *)&list_elem_ptr); if (retval != ERROR_OK) { - LOG_OUTPUT( - "Error reading first thread item location in FreeRTOS thread list\r\n"); + LOG_OUTPUT("Error reading first thread item location in FreeRTOS thread list\r\n"); + free(list_of_lists); return retval; } @@ -281,8 +289,8 @@ static int FreeRTOS_update_threads(struct rtos *rtos) param->pointer_width, (uint8_t *)&(rtos->thread_details[tasks_found].threadid)); if (retval != ERROR_OK) { - LOG_OUTPUT( - "Error reading thread list item object in FreeRTOS thread list\r\n"); + LOG_OUTPUT("Error reading thread list item object in FreeRTOS thread list\r\n"); + free(list_of_lists); return retval; } @@ -297,8 +305,8 @@ static int FreeRTOS_update_threads(struct rtos *rtos) FREERTOS_THREAD_NAME_STR_SIZE, (uint8_t *)&tmp_str); if (retval != ERROR_OK) { - LOG_OUTPUT( - "Error reading first thread item location in FreeRTOS thread list\r\n"); + LOG_OUTPUT("Error reading first thread item location in FreeRTOS thread list\r\n"); + free(list_of_lists); return retval; } tmp_str[FREERTOS_THREAD_NAME_STR_SIZE-1] = '\x00'; @@ -331,12 +339,13 @@ static int FreeRTOS_update_threads(struct rtos *rtos) param->pointer_width, (uint8_t *)&list_elem_ptr); if (retval != ERROR_OK) { - LOG_OUTPUT( - "Error reading next thread item location in FreeRTOS thread list\r\n"); + LOG_OUTPUT("Error reading next thread item location in FreeRTOS thread list\r\n"); + free(list_of_lists); return retval; } } } + free(list_of_lists); rtos->thread_count = tasks_found; return 0;