Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pnpacpi: fix potential corruption on "pnpacpi: exceeded the max number of IRQ resources 2"

PNP_MAX_IRQ is 2
If a device invokes pnpacpi_parse_allocated_irqresource() 0, 1, or 2 times, we are happy.
The 3rd time, we will fail and print "pnpacpi: exceeded the max number of IRQ resources: 2"
The 4th and subsequent calls (if this ever happened) would silently scribble on
irq_resource[2], which doesn't actualy exist.

Found-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Len Brown and committed by
Linus Torvalds
0093cb11 94bc891b

+6 -4
+6 -4
drivers/pnp/pnpacpi/rsparser.c
··· 84 84 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) && 85 85 i < PNP_MAX_IRQ) 86 86 i++; 87 - if (i >= PNP_MAX_IRQ && !warned) { 88 - printk(KERN_WARNING "pnpacpi: exceeded the max number of IRQ " 89 - "resources: %d \n", PNP_MAX_IRQ); 90 - warned = 1; 87 + if (i >= PNP_MAX_IRQ) { 88 + if (!warned) { 89 + printk(KERN_WARNING "pnpacpi: exceeded the max number" 90 + " of IRQ resources: %d\n", PNP_MAX_IRQ); 91 + warned = 1; 92 + } 91 93 return; 92 94 } 93 95 /*