]> git.sur5r.net Git - openocd/commitdiff
jtag/core: free all taps and daps in adapter_quit()
authorTomas Vanek <vanekt@fbl.cz>
Wed, 14 Feb 2018 23:56:44 +0000 (00:56 +0100)
committerTomas Vanek <vanekt@fbl.cz>
Thu, 15 Mar 2018 17:09:09 +0000 (17:09 +0000)
Change-Id: I74496f6ddfb0a72b2933e8d682a73a694b8d107b
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4411
Tested-by: jenkins
src/jtag/core.c

index 8c79eb2302c3b643f3750a400270c0a3bbaea6ad..df4afeb9d42d157085d19c44553683f69c038a9d 100644 (file)
@@ -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;
 }