diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2023-11-05 17:02:26 +0100 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2023-11-18 11:16:27 +0000 |
commit | d4575b647a3603200a9bb4a784d170f792ab88d0 (patch) | |
tree | e1858210ef7aa136f4fc7e3aee533dde829f9286 /src | |
parent | b39072f2ef72f02601b40931d3a38c465804a906 (diff) | |
download | riscv-openocd-d4575b647a3603200a9bb4a784d170f792ab88d0.zip riscv-openocd-d4575b647a3603200a9bb4a784d170f792ab88d0.tar.gz riscv-openocd-d4575b647a3603200a9bb4a784d170f792ab88d0.tar.bz2 |
target: fix segmentation fault on target create
In the unusual (and even incorrect) case of running the command
target create ...
before defining an adapter and the associated transport, the
command causes a segmentation fault. E.g.:
openocd -c 'target create cpu cortex-m -endian little'
Check that get_current_transport() returns a valid pointer before
referencing it.
Change-Id: I9796a7e92196ef3df5c7152b27c34102045dc9e7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7962
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
Diffstat (limited to 'src')
-rw-r--r-- | src/target/target.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/target/target.c b/src/target/target.c index d368cb5..148bc9f 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -6143,7 +6143,7 @@ static int target_create(struct jim_getopt_info *goi) if (e != JIM_OK) return e; struct transport *tr = get_current_transport(); - if (tr->override_target) { + if (tr && tr->override_target) { e = tr->override_target(&cp); if (e != ERROR_OK) { LOG_ERROR("The selected transport doesn't support this target"); |