diff --git a/src/target/arm_dap.c b/src/target/arm_dap.c index 94edfc09d..18e77b50f 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);