target/xtensa: Correct assert condition in handle_interrupt()
PATCH 1/1 target/xtensa: Correct assert condition in handle_interrupt()
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
---
Spotted because Coverity (correctly) thought the issue was still outstanding.
--- target/xtensa/exc_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/xtensa/exc_helper.c +1 -1
@@ -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 ];
Signature · 1 line
2.34.1
Quoted 8 lines · Peter Maydell
In commit
ad18376b90c8101we 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_vectoris an array ofuint32_t, so we should bounds check the index againstARRAY_SIZE(...), not againstsizeof().Resolves: Coverity CID 1507131
Quoted 8 lines
Fixes ad18376b90c8101 ("target/xtensa: Assert that interrupt level is within bounds")Signed-off-by Peter Maydell <[email protected]>---
Spotted because Coverity (correctly) thought the issue was still outstanding.--- target/xtensa/exc_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 2 lines
Thanks. -- Max
Quoted 7 lines · Peter Maydell
In commit
ad18376b90c8101we 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_vectoris an array ofuint32_t, so we should bounds check the index againstARRAY_SIZE(...), not againstsizeof().Resolves: Coverity CID 1507131
Quoted 8 lines
Fixes ad18376b90c8101 ("target/xtensa: Assert that interrupt level is within bounds")Signed-off-by Peter Maydell <[email protected]>---
Spotted because Coverity (correctly) thought the issue was still outstanding.--- target/xtensa/exc_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)