[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/21] target/loongarch/op_helper: Fix coverity cond_at_most error
From: |
Richard Henderson |
Subject: |
[PULL 06/21] target/loongarch/op_helper: Fix coverity cond_at_most error |
Date: |
Tue, 19 Jul 2022 23:29:45 +0530 |
From: Xiaojuan Yang <yangxiaojuan@loongson.cn>
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>
---
target/loongarch/op_helper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/loongarch/op_helper.c b/target/loongarch/op_helper.c
index 4b429b6699..568c071601 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)
--
2.34.1
- [PULL 00/21] loongarch patch queue, Richard Henderson, 2022/07/19
- [PULL 01/21] tests/docker/dockerfiles: Add debian-loongarch-cross.docker, Richard Henderson, 2022/07/19
- [PULL 02/21] target/loongarch: Fix loongarch_cpu_class_by_name, Richard Henderson, 2022/07/19
- [PULL 03/21] hw/intc/loongarch_pch_pic: Fix bugs for update_irq function, Richard Henderson, 2022/07/19
- [PULL 04/21] target/loongarch/cpu: Fix coverity errors about excp_names, Richard Henderson, 2022/07/19
- [PULL 05/21] target/loongarch/tlb_helper: Fix coverity integer overflow error, Richard Henderson, 2022/07/19
- [PULL 06/21] target/loongarch/op_helper: Fix coverity cond_at_most error,
Richard Henderson <=
- [PULL 07/21] target/loongarch/cpu: Fix cpucfg default value, Richard Henderson, 2022/07/19
- [PULL 08/21] fpu/softfloat: Add LoongArch specializations for pickNaN*, Richard Henderson, 2022/07/19
- [PULL 09/21] target/loongarch: Fix float_convd/float_convs test failing, Richard Henderson, 2022/07/19
- [PULL 11/21] tests/tcg/loongarch64: Add clo related instructions test, Richard Henderson, 2022/07/19
- [PULL 10/21] tests/tcg/loongarch64: Add float reference files, Richard Henderson, 2022/07/19
- [PULL 12/21] tests/tcg/loongarch64: Add div and mod related instructions test, Richard Henderson, 2022/07/19
- [PULL 13/21] tests/tcg/loongarch64: Add fclass test, Richard Henderson, 2022/07/19
- [PULL 14/21] tests/tcg/loongarch64: Add fp comparison instructions test, Richard Henderson, 2022/07/19
- [PULL 16/21] hw/loongarch: Add fw_cfg table support, Richard Henderson, 2022/07/19
- [PULL 17/21] hw/loongarch: Add uefi bios loading support, Richard Henderson, 2022/07/19