Skip to content

Commit

Permalink
genirq: Protect access to irq_desc->action in can_request_irq()
Browse files Browse the repository at this point in the history
can_request_irq() accesses and dereferences irq_desc->action w/o
holding irq_desc->lock. So action can be freed on another CPU before
it's dereferenced. Unlikely, but ...

Protect it with desc->lock.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Thomas Gleixner committed Mar 24, 2010
1 parent 0b1adaa commit cc8c3b7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernel/irq/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,18 +382,22 @@ int can_request_irq(unsigned int irq, unsigned long irqflags)
{
struct irq_desc *desc = irq_to_desc(irq);
struct irqaction *action;
unsigned long flags;

if (!desc)
return 0;

if (desc->status & IRQ_NOREQUEST)
return 0;

raw_spin_lock_irqsave(&desc->lock, flags);
action = desc->action;
if (action)
if (irqflags & action->flags & IRQF_SHARED)
action = NULL;

raw_spin_unlock_irqrestore(&desc->lock, flags);

return !action;
}

Expand Down

0 comments on commit cc8c3b7

Please sign in to comment.