diff options
author | Lukas Auer <lukas.auer@aisec.fraunhofer.de> | 2018-11-22 11:26:21 +0100 |
---|---|---|
committer | Andes <uboot@andestech.com> | 2018-11-26 13:57:30 +0800 |
commit | e8b522b1df8b5874e08b53f6e5aef8a2c458446b (patch) | |
tree | 3cb9fc9d007445d6613de2304b4ec8966ba358fd /arch/riscv | |
parent | 5a441736b7dda7fd4dde0a2417aeab59a9ef9424 (diff) | |
download | u-boot-e8b522b1df8b5874e08b53f6e5aef8a2c458446b.tar.gz u-boot-e8b522b1df8b5874e08b53f6e5aef8a2c458446b.tar.xz u-boot-e8b522b1df8b5874e08b53f6e5aef8a2c458446b.zip |
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 <lukas.auer@aisec.fraunhofer.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Rick Chen <rick@andestech.com>
Diffstat (limited to 'arch/riscv')
-rw-r--r-- | arch/riscv/lib/interrupts.c | 8 |
1 files changed, 6 insertions, 2 deletions
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"); + } } |