target/arm_dap: fix segmentation fault in 'dap info' cmd 60/4860/2
authorTomas Vanek <vanekt@fbl.cz>
Sat, 19 Jan 2019 14:58:49 +0000 (15:58 +0100)
committerMatthias Welwarsky <matthias@welwarsky.de>
Wed, 23 Jan 2019 15:25:53 +0000 (15:25 +0000)
'dap info' command fails hard on a hla target.

Change-Id: Ia188b1afe527e0ed64512d1bddadd507f978e40b
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4860
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
src/target/arm_dap.c

index 3adb4ed..119e511 100644 (file)
@@ -313,6 +313,11 @@ COMMAND_HANDLER(handle_dap_info_command)
        struct adiv5_dap *dap = arm->dap;
        uint32_t apsel;
 
+       if (dap == NULL) {
+               LOG_ERROR("DAP instance not available. Probably a HLA target...");
+               return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+       }
+
        switch (CMD_ARGC) {
                case 0:
                        apsel = dap->apsel;