Skip to content

Commit

Permalink
pnpacpi: fix potential corruption on "pnpacpi: exceeded the max numbe…
Browse files Browse the repository at this point in the history
…r 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>
  • Loading branch information
Len Brown authored and Linus Torvalds committed Apr 23, 2008
1 parent 94bc891 commit 0093cb1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/pnp/pnpacpi/rsparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res,
while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) &&
i < PNP_MAX_IRQ)
i++;
if (i >= PNP_MAX_IRQ && !warned) {
printk(KERN_WARNING "pnpacpi: exceeded the max number of IRQ "
"resources: %d \n", PNP_MAX_IRQ);
warned = 1;
if (i >= PNP_MAX_IRQ) {
if (!warned) {
printk(KERN_WARNING "pnpacpi: exceeded the max number"
" of IRQ resources: %d\n", PNP_MAX_IRQ);
warned = 1;
}
return;
}
/*
Expand Down

0 comments on commit 0093cb1

Please sign in to comment.