From 60d570159012e33c221963a4c62a80a70b06301e Mon Sep 17 00:00:00 2001 From: Paul Fertser Date: Fri, 6 Nov 2015 20:53:55 +0300 Subject: [PATCH] target: cortex_a: add deinit_target handler to free memory Tested with Valgrind accesing a Pandaboard. Change-Id: I51bba044974ecfc4d418998816d44a8563264123 Signed-off-by: Paul Fertser Reviewed-on: http://openocd.zylin.com/3101 Tested-by: jenkins Reviewed-by: Freddie Chopin --- src/target/cortex_a.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c index d0260daeb..e2d433a6c 100644 --- a/src/target/cortex_a.c +++ b/src/target/cortex_a.c @@ -3121,6 +3121,16 @@ static int cortex_r4_target_create(struct target *target, Jim_Interp *interp) return cortex_a_init_arch_info(target, cortex_a, target->tap); } +static void cortex_a_deinit_target(struct target *target) +{ + struct cortex_a_common *cortex_a = target_to_cortex_a(target); + struct arm_dpm *dpm = &cortex_a->armv7a_common.dpm; + + free(cortex_a->brp_list); + free(dpm->dbp); + free(dpm->dwp); + free(cortex_a); +} static int cortex_a_mmu(struct target *target, int *enabled) { @@ -3365,6 +3375,7 @@ struct target_type cortexa_target = { .target_create = cortex_a_target_create, .init_target = cortex_a_init_target, .examine = cortex_a_examine, + .deinit_target = cortex_a_deinit_target, .read_phys_memory = cortex_a_read_phys_memory, .write_phys_memory = cortex_a_write_phys_memory, @@ -3449,4 +3460,5 @@ struct target_type cortexr4_target = { .target_create = cortex_r4_target_create, .init_target = cortex_a_init_target, .examine = cortex_a_examine, + .deinit_target = cortex_a_deinit_target, };