]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
target/xtensa: Correct assert condition in handle_interrupt()
authorPeter Maydell <peter.maydell@linaro.org>
Wed, 31 Jul 2024 17:22:46 +0000 (18:22 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Thu, 1 Aug 2024 09:59:01 +0000 (10:59 +0100)
In commit ad18376b90c8101 we added an assert that the level value was
in-bounds for the array we're about to index into.  However, the
assert condition is wrong -- env->config->interrupt_vector is an
array of uint32_t, so we should bounds check the index against
ARRAY_SIZE(...), not against sizeof().

Resolves: Coverity CID 1507131
Fixes: ad18376b90c8101 ("target/xtensa: Assert that interrupt level is within bounds")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20240731172246.3682311-1-peter.maydell@linaro.org

target/xtensa/exc_helper.c

index 0514c2c1f32a31a90b99861861ad7a0045caedd8..ca629f071d1713455e8c37f59a0361107e86c450 100644 (file)
@@ -171,7 +171,7 @@ static void handle_interrupt(CPUXtensaState *env)
 
         if (level > 1) {
             /* env->config->nlevel check should have ensured this */
-            assert(level < sizeof(env->config->interrupt_vector));
+            assert(level < ARRAY_SIZE(env->config->interrupt_vector));
 
             env->sregs[EPC1 + level - 1] = env->pc;
             env->sregs[EPS2 + level - 2] = env->sregs[PS];