This is an automated email from Gerrit. Antonio Borneo ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/5698
-- gerrit commit 96314c0caad1c3b64cdee4f7e2b573a8e04196df Author: Antonio Borneo <[email protected]> Date: Mon May 25 11:28:22 2020 +0200 target/arm9tdmi: fix memory leak of register cache There is no method to free the register cache, allocated in arm9tdmi_build_reg_cache(), so we get a memory leak. Issue identified by tracking all calls to arm_build_reg_cache(). Implement the method arm9tdmi_deinit_target() that in turn calls arm9tdmi_free_reg_cache(). NOT TESTED on real HW, I will rely on gerrit reviewer for tests. Change-Id: If2bed02c516051ce4d0eb29b204a3f3337fe5d6a Signed-off-by: Antonio Borneo <[email protected]> diff --git a/src/target/arm9tdmi.c b/src/target/arm9tdmi.c index 6ab06ed..e643b7f 100644 --- a/src/target/arm9tdmi.c +++ b/src/target/arm9tdmi.c @@ -711,6 +711,13 @@ static void arm9tdmi_build_reg_cache(struct target *target) (*cache_p) = arm_build_reg_cache(target, arm); } +static void arm9tdmi_free_reg_cache(struct target *target) +{ + struct arm *arm = target_to_arm(target); + + arm_free_reg_cache(arm); +} + int arm9tdmi_init_target(struct command_context *cmd_ctx, struct target *target) { @@ -719,6 +726,11 @@ int arm9tdmi_init_target(struct command_context *cmd_ctx, return ERROR_OK; } +void arm9tdmi_deinit_target(struct target *target) +{ + arm9tdmi_free_reg_cache(target); +} + int arm9tdmi_init_arch_info(struct target *target, struct arm7_9_common *arm7_9, struct jtag_tap *tap) { @@ -921,6 +933,7 @@ struct target_type arm9tdmi_target = { .commands = arm9tdmi_command_handlers, .target_create = arm9tdmi_target_create, .init_target = arm9tdmi_init_target, + .deinit_target = arm9tdmi_deinit_target, .examine = arm7_9_examine, .check_reset = arm7_9_check_reset, }; diff --git a/src/target/arm9tdmi.h b/src/target/arm9tdmi.h index c6f0ccf..56946f7 100644 --- a/src/target/arm9tdmi.h +++ b/src/target/arm9tdmi.h @@ -26,6 +26,7 @@ int arm9tdmi_init_target(struct command_context *cmd_ctx, struct target *target); +void arm9tdmi_deinit_target(struct target *target); int arm9tdmi_init_arch_info(struct target *target, struct arm7_9_common *arm7_9, struct jtag_tap *tap); extern const struct command_registration arm9tdmi_command_handlers[]; -- _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
