openocd/src
Tomas Vanek 3c296bd194 jtag/drivers/ulink: fix clang static analyzer warnings
scan-build-9:
Description: Potential leak of memory pointed to by 'cmd'
File: /home/vanekt/openocd/scanbuild9/../src/jtag/drivers/ulink.c
Line: 1075

Description: Potential leak of memory pointed to by 'cmd'
File: /home/vanekt/openocd/scanbuild9/../src/jtag/drivers/ulink.c
Line: 1275

ulink_append_xxx_cmd() functions allocate memory for cmd
and then call ulink_allocate_payload(), which allocates cmd->payload_out
or cmd->payload_in.

ulink_append_queue() checks the size of queue and if the new payload
does not fit, calls ulink_execute_queued_commands() and then
ulink_post_process_queue(). If any of these two fails, an error is
returned, allocated cmd struct leaks and the queue is left in an undefined
state.

Change ulink_append_queue() flow to proceed to appending cmd to the queue
even in the case of fail in previous ulink_execute_queued_commands()
or ulink_post_process_queue(). In case of fail then clear the queue
including the last appended cmd.

Change-Id: I967c07af19e9020c93bcb4ef403cf1f557dd1db1
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5370
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2020-04-20 18:26:58 +01:00
..
flash flash/nand/core: fix clang static analyzer warning 2020-04-20 18:25:36 +01:00
helper helper/binarybuffer: fix clang static analyzer warnings 2020-03-07 15:30:05 +00:00
jtag jtag/drivers/ulink: fix clang static analyzer warnings 2020-04-20 18:26:58 +01:00
pld helper/command: change prototype of command_print/command_print_sameline 2019-05-14 19:37:11 +01:00
rtos Revert "rtos/FreeRTOS: Fix FreeRTOS thread list reading" 2020-04-15 12:40:31 +01:00
server server: set connection::input_pending type to bool 2020-04-13 17:52:06 +01:00
svf openocd: fix minor inconsistencies after renaming "adapter" command 2020-01-29 05:36:30 +00:00
target target/arc: remove saving context during reset 2020-04-20 18:22:53 +01:00
transport adi_v5_dapdirect: add support for adapter drivers that provide DAP API 2020-01-14 11:40:25 +00:00
xsvf xsvf: fix memory leak 2020-01-16 09:44:33 +00:00
Makefile.am Convert to non-recursive make 2016-12-08 16:23:10 +00:00
hello.c helper/command: change prototype of command_print/command_print_sameline 2019-05-14 19:37:11 +01:00
hello.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
main.c Remove FSF address from GPL notices 2016-05-24 22:30:01 +01:00
openocd.c mflash: Remove this broken flash driver 2019-07-28 21:17:47 +01:00
openocd.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00