arch: Fix bounds checking for dynamic shared interrupts

Fixes z_isr_install() and z_isr_uninstall() routines to check the isr
table index against the correct number of isr table entries. This
prevents out-of-bounds isr table accesses when
CONFIG_GEN_IRQ_START_VECTOR is greater than zero, such as on the ARC
architecture.

Coverity-CID: 347187
Coverity-CID: 347189
Coverity-CID: 347097
Coverity-CID: 347203
Coverity-CID: 347210

Signed-off-by: Maureen Helm <maureen.helm@analog.com>
This commit is contained in:
Maureen Helm 2024-02-17 12:35:26 -06:00 committed by Henrik Brix Andersen
parent a6e9f12ca8
commit 28555ae9f4

View file

@ -50,7 +50,7 @@ void z_isr_install(unsigned int irq, void (*routine)(const void *),
table_idx = z_get_sw_isr_table_idx(irq); table_idx = z_get_sw_isr_table_idx(irq);
/* check for out of bounds table index */ /* check for out of bounds table index */
if (table_idx >= CONFIG_NUM_IRQS) { if (table_idx >= IRQ_TABLE_SIZE) {
return; return;
} }
@ -170,7 +170,7 @@ int z_isr_uninstall(unsigned int irq,
table_idx = z_get_sw_isr_table_idx(irq); table_idx = z_get_sw_isr_table_idx(irq);
/* check for out of bounds table index */ /* check for out of bounds table index */
if (table_idx >= CONFIG_NUM_IRQS) { if (table_idx >= IRQ_TABLE_SIZE) {
return -EINVAL; return -EINVAL;
} }