瀏覽代碼

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>
Joe Jin 14 年之前
父節點
當前提交
110e7c7e4f
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      drivers/xen/events.c

+ 3 - 0
drivers/xen/events.c

@@ -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;
 }