xen-event: validate irq before get evtchn by irq
Subsystems (2)
PATCH 1/1 xen-event: validate irq before get evtchn by irq
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.
--- events.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/xen/events.c +3 -0
@@ -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; }
Quoted 5 lines · Joe Jin
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.
You've accidentally got "by irq" twice there and "may irq is not a valid one" doesn't read quite right.
Perhaps something like:
"When getting an event channel from an IRQ if the IRQ is not valid then warn and return an error in the form of the invalid event channel.
This catches errors such as trying to notify an IRQ before connecting to the backend (e.g. during suspend/resume)."
Quoted 4 lines
Please review and comment.
Signed-off-by Joe Jin <[email protected]>Tested-by Gurudas Pai <[email protected]>
Thanks,
Ian.
Quoted 23 lines
Cc Jeremy Fitzhardinge <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>Cc Andrew Morton <[email protected]>--- events.c | 3 +++ 1 file changed, 3 insertions(+)drivers/xen/events.c +3
-0@@ -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; }