diff options
author | Megan Wachs <megan@sifive.com> | 2017-05-05 09:37:26 -0700 |
---|---|---|
committer | Palmer Dabbelt <palmer@dabbelt.com> | 2017-05-05 11:05:28 -0700 |
commit | fa8d7adf33986302100313a791418423a7d4c758 (patch) | |
tree | c6e009ca973466d4d5100db97fb880e68c598f09 /src | |
parent | 325f17f6ec897e3eb4c2cb3ee620dcc74b49c9f3 (diff) | |
download | riscv-openocd-fa8d7adf33986302100313a791418423a7d4c758.zip riscv-openocd-fa8d7adf33986302100313a791418423a7d4c758.tar.gz riscv-openocd-fa8d7adf33986302100313a791418423a7d4c758.tar.bz2 |
Avoid accessing null target->reg_cache
GDB might request registers even if target was not successfully initialized.
Diffstat (limited to 'src')
-rw-r--r-- | src/target/riscv/riscv.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c index 42c2f87..d754cd6 100644 --- a/src/target/riscv/riscv.c +++ b/src/target/riscv/riscv.c @@ -414,6 +414,12 @@ static int riscv_get_gdb_reg_list(struct target *target, if (!*reg_list) { return ERROR_FAIL; } + + if (!target->reg_cache) { + LOG_ERROR("Target not initialized. Return ERROR_FAIL."); + return ERROR_FAIL; + } + for (int i = 0; i < *reg_list_size; i++) { assert(target->reg_cache->reg_list[i].size > 0); (*reg_list)[i] = &target->reg_cache->reg_list[i]; |