Skip to content

Commit

Permalink
arch/risc-v: guard tcb->name usage
Browse files Browse the repository at this point in the history
Add guard for tcb->name field usage as it is not always available.

Signed-off-by: Yanfeng Liu <[email protected]>
  • Loading branch information
yf13 committed May 22, 2024
1 parent 8b9568e commit 6661ab4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/risc-v/src/common/riscv_exception.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 6661ab4

Please sign in to comment.