HV: Fixes index out of bounds for addressing irq.

NR_MAX_IRQS is defined as 272 and IRQ_INVALID as 273 which implies
that 272 is a valid irq number. In this case, an illegal access can
occur at run time when irq_desc_array[] or irq_count[] is accessed
with index 272. This fix stops the illegal access by renaming
NR_MAX_IRQS to NR_IRQS and then places proper conditions for range
checks. If the index is >= NR_IRQS, then index is invalid otherwise
its considered valid for accessing irq arrays. IRQ_INVALID definition
is also changed to 0xffffffffU to indicate maximum unsigned value.

Signed-off-by: Madeeha Javed <madeeha_javed@mentor.com>
This commit is contained in:
Madeeha Javed
2018-07-16 14:39:45 +05:00
committed by lijinxia
parent 988a3fe0d6
commit a257f2fadc
5 changed files with 18 additions and 18 deletions

View File

@@ -362,7 +362,7 @@ void setup_ioapic_irq(void)
}
/* pinned irq before use it */
if (irq_mark_used(gsi) > NR_MAX_IRQS) {
if (irq_mark_used(gsi) >= NR_IRQS) {
pr_err("failed to alloc IRQ[%d]", gsi);
gsi++;
continue;