Skip to content

Commit

Permalink
xen/event: validate irq before get evtchn by irq
Browse files Browse the repository at this point in the history
When retrieving the event channel number from irq, the irq
number may not be valid under some conditions.

So far that can be when we suspend/resume and irq ends with -1.
Validate and return sanitized irq and provide diagnostics information.

[v3: added unlikely on the WARN path]
[v2: reworded the commit message]
Signed-off-by: Joe Jin <[email protected]>
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
Tested-by: Gurudas Pai <[email protected]>
Cc: Ian Campbell <[email protected]>
Cc: Jeremy Fitzhardinge <[email protected]>
Cc: Andrew Morton <[email protected]>
  • Loading branch information
joejin00 authored and konradwilk committed Jan 10, 2011
1 parent fc550e9 commit 110e7c7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/xen/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ static struct irq_info *info_for_irq(unsigned irq)

static unsigned int evtchn_from_irq(unsigned irq)
{
if (unlikely(WARN(irq < 0 || irq >= nr_irqs, "Invalid irq %d!\n", irq)))
return 0;

return info_for_irq(irq)->evtchn;
}

Expand Down

0 comments on commit 110e7c7

Please sign in to comment.