From 6dcd255b7bde5d7d3a8805c3a0e81f5edf42ccf4 Mon Sep 17 00:00:00 2001 From: Tomas Vanek Date: Fri, 13 Mar 2020 15:13:21 +0100 Subject: jtag/drivers/ulink: fix clang static analyzer warning scan-build-9: Description: Access to field 'payload_in' results in a dereference of a null pointer (loaded from field 'queue_start') File: src/jtag/drivers/ulink.c Line: 2216 Set input/output_signals conditionally if ulink_append_get_signals_cmd() and ulink_execute_queued_commands() returns no error. Do not fail driver initialisation as the signals are only printed. Change-Id: I6c842f0e9a604712abf7444a2fa95ba5810de1ff Signed-off-by: Tomas Vanek Reviewed-on: http://openocd.zylin.com/5520 Tested-by: jenkins Reviewed-by: Antonio Borneo Reviewed-by: Oleksij Rempel --- src/jtag/drivers/ulink.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/jtag/drivers/ulink.c b/src/jtag/drivers/ulink.c index 9235eb8..4066d61 100644 --- a/src/jtag/drivers/ulink.c +++ b/src/jtag/drivers/ulink.c @@ -2210,14 +2210,17 @@ static int ulink_init(void) } ulink_clear_queue(ulink_handle); - ulink_append_get_signals_cmd(ulink_handle); - ulink_execute_queued_commands(ulink_handle, 200); + ret = ulink_append_get_signals_cmd(ulink_handle); + if (ret == ERROR_OK) + ret = ulink_execute_queued_commands(ulink_handle, 200); - /* Post-process the single CMD_GET_SIGNALS command */ - input_signals = ulink_handle->queue_start->payload_in[0]; - output_signals = ulink_handle->queue_start->payload_in[1]; + if (ret == ERROR_OK) { + /* Post-process the single CMD_GET_SIGNALS command */ + input_signals = ulink_handle->queue_start->payload_in[0]; + output_signals = ulink_handle->queue_start->payload_in[1]; - ulink_print_signal_states(input_signals, output_signals); + ulink_print_signal_states(input_signals, output_signals); + } ulink_clear_queue(ulink_handle); -- cgit v1.1