Skip to content

Commit

Permalink
target/xtensa: Correct assert condition in handle_interrupt()
Browse files Browse the repository at this point in the history
In commit ad18376 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: ad18376 ("target/xtensa: Assert that interrupt level is within bounds")
Signed-off-by: Peter Maydell <[email protected]>
Acked-by: Max Filippov <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
  • Loading branch information
pm215 committed Aug 1, 2024
1 parent 55f9f4e commit 5e8e4f0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion target/xtensa/exc_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 5e8e4f0

Please sign in to comment.