From: Lukas Auer Date: Thu, 22 Nov 2018 10:26:21 +0000 (+0100) Subject: riscv: treat undefined exception codes as reserved X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=e8b522b1df8b5874e08b53f6e5aef8a2c458446b;p=u-boot.git riscv: treat undefined exception codes as reserved Undefined exception codes currently lead to an out-of-bounds array access. Prevent this by treating undefined exception codes as "reserved". Signed-off-by: Lukas Auer Reviewed-by: Bin Meng Reviewed-by: Rick Chen --- diff --git a/arch/riscv/lib/interrupts.c b/arch/riscv/lib/interrupts.c index 6a12818c2b..d0d8de500e 100644 --- a/arch/riscv/lib/interrupts.c +++ b/arch/riscv/lib/interrupts.c @@ -81,6 +81,10 @@ static void _exit_trap(ulong code, ulong epc, struct pt_regs *regs) "Store/AMO page fault", }; - printf("exception code: %ld , %s , epc %lx , ra %lx\n", - code, exception_code[code], epc, regs->ra); + if (code < ARRAY_SIZE(exception_code)) { + printf("exception code: %ld , %s , epc %lx , ra %lx\n", + code, exception_code[code], epc, regs->ra); + } else { + printf("Reserved\n"); + } }