This is an automated email from Gerrit.

"Grant Ramsay <grant.ram...@hotmail.com>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8415

-- gerrit

commit dfac674f2930c8bc925cdbfb9fd60680f2b9afe7
Author: Grant Ramsay <grant.ram...@hotmail.com>
Date:   Wed Jul 24 10:57:03 2024 +1200

    target: arm_dap: Fix crash in 'dap info' command
    
    Check target is ARM before dereference. Running 'dap info'
    when the current target is a mem_ap would cause a crash
    
    Change-Id: I0c765f915f2ef7b9a7d20c934e144559ca4e5f1c
    Signed-off-by: Grant Ramsay <grant.ram...@hotmail.com>

diff --git a/src/target/arm_dap.c b/src/target/arm_dap.c
index 9f4afae743..55e916845e 100644
--- a/src/target/arm_dap.c
+++ b/src/target/arm_dap.c
@@ -452,8 +452,15 @@ COMMAND_HANDLER(handle_dap_info_command)
        struct adiv5_dap *dap = arm->dap;
        uint64_t apsel;
 
+       if (!is_arm(arm)) {
+               command_print(CMD, "target '%s' is '%s'; not an ARM",
+                       target_name(target),
+                       target_type_name(target));
+               return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+       }
+
        if (!dap) {
-               LOG_ERROR("DAP instance not available. Probably a HLA 
target...");
+               command_print(CMD, "DAP instance not available. Probably a HLA 
target...");
                return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
        }
 

-- 

Reply via email to