qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 5/5] target/loongarch/op_helper: Fix coverity cond_at_most er


From: Richard Henderson
Subject: Re: [PATCH 5/5] target/loongarch/op_helper: Fix coverity cond_at_most error
Date: Wed, 13 Jul 2022 21:35:52 +0530
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1

On 7/13/22 15:20, Xiaojuan Yang wrote:
The boundary size of cpucfg array should be 0 to 20. So,
using index bigger than 20 to access cpucfg[] must be forbidden.

You must update the comment to match the code,
which no longer mentions "20" at all.  With that change,

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


Fix coverity CID: 1489760

Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn>
---
  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)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]