X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Ftarget%2Farm_dap.c;h=119e5117d2e5ffa186e1d055391e0ebc625f41f2;hb=3b39618eb5ab2bcceb00acaba3df303c4d9fa51e;hp=3be4d7199c1c9122d33d4ee7b335b36ade13cc55;hpb=9363705820d9552bd24a4e876041a90a881ede55;p=openocd.git diff --git a/src/target/arm_dap.c b/src/target/arm_dap.c index 3be4d7199c..119e5117d2 100644 --- a/src/target/arm_dap.c +++ b/src/target/arm_dap.c @@ -48,7 +48,7 @@ static void dap_instance_init(struct adiv5_dap *dap) { int i; /* Set up with safe defaults */ - for (i = 0; i <= 255; i++) { + for (i = 0; i <= DP_APSEL_MAX; i++) { dap->ap[i].dap = dap; dap->ap[i].ap_num = i; /* memaccess_tck max is 255 */ @@ -313,13 +313,18 @@ 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; break; case 1: COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel); - if (apsel >= 256) + if (apsel > DP_APSEL_MAX) return ERROR_COMMAND_SYNTAX_ERROR; break; default: