aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2022-01-27 10:00:06 -0800
committerGitHub <noreply@github.com>2022-01-27 10:00:06 -0800
commit6f3daf38c76db24422023c42f66d128cedb32813 (patch)
treebd1196fe461e3ebd40706306131bcab33163c3ab /src
parentcc0ecfb6d5b939bd109ea84b07b5eab3cdf80316 (diff)
downloadriscv-openocd-6f3daf38c76db24422023c42f66d128cedb32813.zip
riscv-openocd-6f3daf38c76db24422023c42f66d128cedb32813.tar.gz
riscv-openocd-6f3daf38c76db24422023c42f66d128cedb32813.tar.bz2
Fix small memory leak. (#672)
Change-Id: Ia11ab9bcf860f770ea64ad867102c74b898f6b66 Signed-off-by: Tim Newsome <tim@sifive.com>
Diffstat (limited to 'src')
-rw-r--r--src/target/riscv/riscv-013.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c
index 1c7d559..ec6821d 100644
--- a/src/target/riscv/riscv-013.c
+++ b/src/target/riscv/riscv-013.c
@@ -2291,9 +2291,11 @@ static int init_target(struct command_context *cmd_ctx,
generic_info->hart_count = &riscv013_hart_count;
generic_info->data_bits = &riscv013_data_bits;
generic_info->print_info = &riscv013_print_info;
- generic_info->version_specific = calloc(1, sizeof(riscv013_info_t));
- if (!generic_info->version_specific)
- return ERROR_FAIL;
+ if (generic_info->version_specific == NULL) {
+ generic_info->version_specific = calloc(1, sizeof(riscv013_info_t));
+ if (!generic_info->version_specific)
+ return ERROR_FAIL;
+ }
generic_info->sample_memory = sample_memory;
riscv013_info_t *info = get_info(target);