aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTomas Vanek <vanekt@fbl.cz>2021-11-10 12:46:42 +0100
committerAntonio Borneo <borneo.antonio@gmail.com>2021-11-20 14:44:38 +0000
commit3eef83e4bd2b112b98d73f8b0947af93c193e0ef (patch)
treed7cf4b88be7c82125c3bac3a80b995268924d014 /src
parent08dac883a14aab398922a4e61d55204d7cef644f (diff)
downloadriscv-openocd-3eef83e4bd2b112b98d73f8b0947af93c193e0ef.zip
riscv-openocd-3eef83e4bd2b112b98d73f8b0947af93c193e0ef.tar.gz
riscv-openocd-3eef83e4bd2b112b98d73f8b0947af93c193e0ef.tar.bz2
target/arm_dap: fix memory leak in error path of dap_create()
Change-Id: I91fa5910670161b62a76fc834b6394c5a6c05395 Suggested-by: Antonio Borneo <borneo.antonio@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6685 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/target/arm_dap.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/target/arm_dap.c b/src/target/arm_dap.c
index 94edfc0..18e77b5 100644
--- a/src/target/arm_dap.c
+++ b/src/target/arm_dap.c
@@ -267,8 +267,11 @@ static int dap_create(struct jim_getopt_info *goi)
dap_commands[0].chain = NULL;
e = register_commands_with_data(cmd_ctx, NULL, dap_commands, dap);
- if (e != ERROR_OK)
+ if (e != ERROR_OK) {
+ free(dap->name);
+ free(dap);
return JIM_ERR;
+ }
list_add_tail(&dap->lh, &all_dap);