From: Antonio Borneo Date: Mon, 15 Apr 2024 15:42:12 +0000 (+0200) Subject: smp: fix SIGSEGV for "smp off" during target examine X-Git-Url: https://review.openocd.org/gitweb?a=commitdiff_plain;h=3eba7b53bf067508197e2455b81fc1375b1d945e;p=openocd.git smp: fix SIGSEGV for "smp off" during target examine The gdb subsystem is initialized after the first target examine, so the field struct target::gdb_service is NULL during examine. A command "smp off" in the examine event handler causes a SIGSEGV during OpenOCD startup. Check for pointer not NULL before dereferencing it. Change-Id: Id115e28be23a957fef1b97ab66d7273f0ea0dce4 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8216 Tested-by: jenkins --- diff --git a/src/target/smp.c b/src/target/smp.c index 50b19d01a0..41ca880d43 100644 --- a/src/target/smp.c +++ b/src/target/smp.c @@ -119,7 +119,7 @@ COMMAND_HANDLER(default_handle_smp_command) head->target->smp = 0; /* fixes the target display to the debugger */ - if (!list_empty(target->smp_targets)) + if (!list_empty(target->smp_targets) && target->gdb_service) target->gdb_service->target = target; return ERROR_OK;