diff options
-rw-r--r-- | common/panic_output.c | 14 | ||||
-rw-r--r-- | include/panic.h | 2 |
2 files changed, 13 insertions, 3 deletions
diff --git a/common/panic_output.c b/common/panic_output.c index e6b48a375d..06b2b7e51e 100644 --- a/common/panic_output.c +++ b/common/panic_output.c @@ -229,10 +229,18 @@ DECLARE_CONSOLE_COMMAND(panicinfo, command_panicinfo, int host_command_panic_info(struct host_cmd_handler_args *args) { + uint32_t pdata_size = pdata_ptr->struct_size; + if (pdata_ptr->magic == PANIC_DATA_MAGIC) { - ASSERT(pdata_ptr->struct_size <= args->response_max); - memcpy(args->response, pdata_ptr, pdata_ptr->struct_size); - args->response_size = pdata_ptr->struct_size; + if (pdata_size > args->response_max) { + panic_printf("Panic data size %d is too " + "large, truncating to %d\n", + pdata_size, args->response_max); + pdata_size = args->response_max; + pdata_ptr->flags |= PANIC_DATA_FLAG_TRUNCATED; + } + memcpy(args->response, pdata_ptr, pdata_size); + args->response_size = pdata_size; /* Data has now been returned */ pdata_ptr->flags |= PANIC_DATA_FLAG_OLD_HOSTCMD; diff --git a/include/panic.h b/include/panic.h index 8a689c4b23..f3910b70ca 100644 --- a/include/panic.h +++ b/include/panic.h @@ -81,6 +81,8 @@ enum panic_arch { #define PANIC_DATA_FLAG_OLD_HOSTCMD (1 << 2) /* Already reported via host event */ #define PANIC_DATA_FLAG_OLD_HOSTEVENT (1 << 3) +/* The data was truncated to fit panic info host cmd */ +#define PANIC_DATA_FLAG_TRUNCATED (1 << 4) /** * Write a string to the panic reporting device |