Skip to content

Commit bb05756

Browse files
timsifiveborneoa
authored andcommitted
Fix small memory leak.
See riscv-collab/riscv-openocd#672 Change-Id: Ia11ab9bcf860f770ea64ad867102c74b898f6b66 Signed-off-by: Tim Newsome <[email protected]> Reviewed-on: https://review.openocd.org/c/openocd/+/6831 Tested-by: jenkins Reviewed-by: zapb <[email protected]> Reviewed-by: Antonio Borneo <[email protected]>
1 parent 0dc0b53 commit bb05756

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/target/riscv/riscv-013.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,9 +2308,11 @@ static int init_target(struct command_context *cmd_ctx,
23082308
generic_info->hart_count = &riscv013_hart_count;
23092309
generic_info->data_bits = &riscv013_data_bits;
23102310
generic_info->print_info = &riscv013_print_info;
2311-
generic_info->version_specific = calloc(1, sizeof(riscv013_info_t));
2312-
if (!generic_info->version_specific)
2313-
return ERROR_FAIL;
2311+
if (!generic_info->version_specific) {
2312+
generic_info->version_specific = calloc(1, sizeof(riscv013_info_t));
2313+
if (!generic_info->version_specific)
2314+
return ERROR_FAIL;
2315+
}
23142316
generic_info->sample_memory = sample_memory;
23152317
riscv013_info_t *info = get_info(target);
23162318

0 commit comments

Comments
 (0)