aboutsummaryrefslogtreecommitdiff
path: root/target
diff options
context:
space:
mode:
authorXiaojuan Yang <yangxiaojuan@loongson.cn>2022-07-15 14:07:40 +0800
committerRichard Henderson <richard.henderson@linaro.org>2022-07-19 21:53:58 +0530
commit064357041d64331e3dbc18629d07abf88ce0f6bb (patch)
tree05521aef2d90f4526413a9fa4e7a091b12f7df00 /target
parent2b3ef8e5c607130dc5a70f12cc7c6ee68c3844df (diff)
downloadqemu-064357041d64331e3dbc18629d07abf88ce0f6bb.zip
qemu-064357041d64331e3dbc18629d07abf88ce0f6bb.tar.gz
qemu-064357041d64331e3dbc18629d07abf88ce0f6bb.tar.bz2
target/loongarch/op_helper: Fix coverity cond_at_most error
The boundary size of cpucfg array should be 0 to ARRAY_SIZE(cpucfg)-1. So, using index bigger than max boundary to access cpucfg[] must be forbidden. Fix coverity CID: 1489760 Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220715060740.1500628-6-yangxiaojuan@loongson.cn> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'target')
-rw-r--r--target/loongarch/op_helper.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/target/loongarch/op_helper.c b/target/loongarch/op_helper.c
index 4b429b6..568c071 100644
--- a/target/loongarch/op_helper.c
+++ b/target/loongarch/op_helper.c
@@ -81,7 +81,7 @@ target_ulong helper_crc32c(target_ulong val, target_ulong m, uint64_t sz)
target_ulong helper_cpucfg(CPULoongArchState *env, target_ulong rj)
{
- return rj > 21 ? 0 : env->cpucfg[rj];
+ return rj >= ARRAY_SIZE(env->cpucfg) ? 0 : env->cpucfg[rj];
}
uint64_t helper_rdtime_d(CPULoongArchState *env)