Commit c2b5a251 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Linus Torvalds

[PATCH] Check the irq number is within bounds

Most of the functions already check. Do the ones that didn't.
Signed-off-by: default avatarMatthew Wilcox <matthew@wil.cx>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2d0ebb36
...@@ -36,6 +36,9 @@ void synchronize_irq(unsigned int irq) ...@@ -36,6 +36,9 @@ void synchronize_irq(unsigned int irq)
{ {
struct irq_desc *desc = irq_desc + irq; struct irq_desc *desc = irq_desc + irq;
if (irq >= NR_IRQS)
return;
while (desc->status & IRQ_INPROGRESS) while (desc->status & IRQ_INPROGRESS)
cpu_relax(); cpu_relax();
} }
...@@ -60,6 +63,9 @@ void disable_irq_nosync(unsigned int irq) ...@@ -60,6 +63,9 @@ void disable_irq_nosync(unsigned int irq)
irq_desc_t *desc = irq_desc + irq; irq_desc_t *desc = irq_desc + irq;
unsigned long flags; unsigned long flags;
if (irq >= NR_IRQS)
return;
spin_lock_irqsave(&desc->lock, flags); spin_lock_irqsave(&desc->lock, flags);
if (!desc->depth++) { if (!desc->depth++) {
desc->status |= IRQ_DISABLED; desc->status |= IRQ_DISABLED;
...@@ -86,6 +92,9 @@ void disable_irq(unsigned int irq) ...@@ -86,6 +92,9 @@ void disable_irq(unsigned int irq)
{ {
irq_desc_t *desc = irq_desc + irq; irq_desc_t *desc = irq_desc + irq;
if (irq >= NR_IRQS)
return;
disable_irq_nosync(irq); disable_irq_nosync(irq);
if (desc->action) if (desc->action)
synchronize_irq(irq); synchronize_irq(irq);
...@@ -108,6 +117,9 @@ void enable_irq(unsigned int irq) ...@@ -108,6 +117,9 @@ void enable_irq(unsigned int irq)
irq_desc_t *desc = irq_desc + irq; irq_desc_t *desc = irq_desc + irq;
unsigned long flags; unsigned long flags;
if (irq >= NR_IRQS)
return;
spin_lock_irqsave(&desc->lock, flags); spin_lock_irqsave(&desc->lock, flags);
switch (desc->depth) { switch (desc->depth) {
case 0: case 0:
...@@ -163,6 +175,9 @@ int setup_irq(unsigned int irq, struct irqaction * new) ...@@ -163,6 +175,9 @@ int setup_irq(unsigned int irq, struct irqaction * new)
unsigned long flags; unsigned long flags;
int shared = 0; int shared = 0;
if (irq >= NR_IRQS)
return -EINVAL;
if (desc->handler == &no_irq_type) if (desc->handler == &no_irq_type)
return -ENOSYS; return -ENOSYS;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment