arch/risc-v: guard tcb->name usage

Add guard for tcb->name field usage as it is not always available.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
This commit is contained in:
Yanfeng Liu 2024-05-22 14:52:42 +08:00 committed by Xiang Xiao
parent 4b2b26c0b0
commit f8749ef0e0

View File

@ -94,7 +94,11 @@ int riscv_exception(int mcause, void *regs, void *args)
#ifdef CONFIG_ARCH_KERNEL_STACK
if ((tcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL)
{
# if CONFIG_TASK_NAME_SIZE > 0
_alert("Segmentation fault in PID %d: %s\n", tcb->pid, tcb->name);
# else
_alert("Segmentation fault in PID %d\n", tcb->pid);
# endif
tcb->flags |= TCB_FLAG_FORCED_CANCEL;