target/loongarch/cpu: Fix coverity errors about excp_names
Fix out-of-bounds errors when access excp_names[] array. the valid boundary size of excp_names should be 0 to ARRAY_SIZE(excp_names)-1. However, the general code do not consider the max boundary. Fix coverity CID: 1489758 Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220715060740.1500628-4-yangxiaojuan@loongson.cn> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
056dac5384
commit
e4ad16f492
|
@ -140,7 +140,7 @@ static void loongarch_cpu_do_interrupt(CPUState *cs)
|
||||||
|
|
||||||
if (cs->exception_index != EXCCODE_INT) {
|
if (cs->exception_index != EXCCODE_INT) {
|
||||||
if (cs->exception_index < 0 ||
|
if (cs->exception_index < 0 ||
|
||||||
cs->exception_index > ARRAY_SIZE(excp_names)) {
|
cs->exception_index >= ARRAY_SIZE(excp_names)) {
|
||||||
name = "unknown";
|
name = "unknown";
|
||||||
} else {
|
} else {
|
||||||
name = excp_names[cs->exception_index];
|
name = excp_names[cs->exception_index];
|
||||||
|
@ -190,8 +190,8 @@ static void loongarch_cpu_do_interrupt(CPUState *cs)
|
||||||
cause = cs->exception_index;
|
cause = cs->exception_index;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qemu_log("Error: exception(%d) '%s' has not been supported\n",
|
qemu_log("Error: exception(%d) has not been supported\n",
|
||||||
cs->exception_index, excp_names[cs->exception_index]);
|
cs->exception_index);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue