Thread (2 messages) 2 messages, 2 authors, 2011-01-07
STALE5682d REVIEWED: 1 (0M)

[patch] xen-event: validate irq before get evtchn by irq

From: Joe Jin <hidden>
Date: 2011-01-07 06:51:11
Also in: lkml, xen-devel
Subsystem: the rest, xen hypervisor interface · Maintainers: Linus Torvalds, Juergen Gross, Stefano Stabellini

Hi,

When get event channel by irq by irq, may irq is not a valid one under
some condition -- so far we found irq is -1 during suspend/resume, so
worth to validate it rather than return incorrect data.

Please review and comment.

Signed-off-by: Joe Jin <redacted>
Tested-by: Gurudas Pai <redacted>
Cc: Ian Campbell <redacted>
Cc: Jeremy Fitzhardinge <redacted>
Cc: Konrad Rzeszutek Wilk <redacted>
Cc: Andrew Morton <akpm@linux-foundation.org>

---
 events.c |    3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index ac7b42f..006dd7b 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -175,6 +175,9 @@ static struct irq_info *info_for_irq(unsigned irq)
 
 static unsigned int evtchn_from_irq(unsigned irq)
 {
+	if (WARN(irq < 0 || irq >= nr_irqs, "Invalid irq %d!\n", irq))
+		return 0;
+
 	return info_for_irq(irq)->evtchn;
 }
 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help