aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen/events.c
diff options
context:
space:
mode:
authorJoe Jin <joe.jin@oracle.com>2011-01-07 01:50:12 -0500
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-01-10 10:46:32 -0500
commit110e7c7e4f8a61a34e0ab88fc9bdf4d5c6d220b2 (patch)
tree9c489bc508c244fb43d97fd79a1618281845d91c /drivers/xen/events.c
parentfc550e95921e109f3778a6b2dc560d63388810ab (diff)
xen/event: validate irq before get evtchn by irq
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 <joe.jin@oracle.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Tested-by: Gurudas Pai <gurudas.pai@oracle.com> Cc: Ian Campbell <ian.campbell@citrix.com> Cc: Jeremy Fitzhardinge <jeremy@goop.org> Cc: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'drivers/xen/events.c')
-rw-r--r--drivers/xen/events.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 4d4a23d4c9f..3df7e477694 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -170,6 +170,9 @@ static struct irq_info *info_for_irq(unsigned irq)
170 170
171static unsigned int evtchn_from_irq(unsigned irq) 171static unsigned int evtchn_from_irq(unsigned irq)
172{ 172{
173 if (unlikely(WARN(irq < 0 || irq >= nr_irqs, "Invalid irq %d!\n", irq)))
174 return 0;
175
173 return info_for_irq(irq)->evtchn; 176 return info_for_irq(irq)->evtchn;
174} 177}
175 178