From: Tomas Vanek Date: Wed, 14 Feb 2018 23:56:44 +0000 (+0100) Subject: jtag/core: free all taps and daps in adapter_quit() X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=63d768824550a9607daef9449eed422bd941ad32;p=openocd jtag/core: free all taps and daps in adapter_quit() Change-Id: I74496f6ddfb0a72b2933e8d682a73a694b8d107b Signed-off-by: Tomas Vanek Reviewed-on: http://openocd.zylin.com/4411 Tested-by: jenkins --- diff --git a/src/jtag/core.c b/src/jtag/core.c index 8c79eb23..df4afeb9 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -1315,6 +1315,7 @@ void jtag_tap_free(struct jtag_tap *tap) free(tap->chip); free(tap->tapname); free(tap->dotted_name); + free(tap->dap); free(tap); } @@ -1472,13 +1473,19 @@ int jtag_init_inner(struct command_context *cmd_ctx) int adapter_quit(void) { - if (!jtag || !jtag->quit) - return ERROR_OK; + if (jtag && jtag->quit) { + /* close the JTAG interface */ + int result = jtag->quit(); + if (ERROR_OK != result) + LOG_ERROR("failed: %d", result); + } - /* close the JTAG interface */ - int result = jtag->quit(); - if (ERROR_OK != result) - LOG_ERROR("failed: %d", result); + struct jtag_tap *t = jtag_all_taps(); + while (t) { + struct jtag_tap *n = t->next_tap; + jtag_tap_free(t); + t = n; + } return ERROR_OK; }