qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] pci: Don't call pci_irq_handler() for a negative in


From: Cédric Le Goater
Subject: [Qemu-devel] [PATCH] pci: Don't call pci_irq_handler() for a negative intx
Date: Wed, 12 Apr 2017 09:12:17 +0200

From: Benjamin Herrenschmidt <address@hidden>

Under some circumstances, pci_intx() can return -1 (when the interrupt
pin in the config space is 0 which normally means no interrupt).

I have seen cases of pci_set_irq() being called on such devices, in
turn causing pci_irq_handler() to be called with "-1" as an argument
which doesn't seem like a terribly good idea.

Signed-off-by: Benjamin Herrenschmidt <address@hidden>
[clg: updated for qemu-2.9 ]
Signed-off-by: Cédric Le Goater <address@hidden>
Reviewed-by: David Gibson <address@hidden>
---
 hw/pci/pci.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: qemu-powernv-2.9.git/hw/pci/pci.c
===================================================================
--- qemu-powernv-2.9.git.orig/hw/pci/pci.c
+++ qemu-powernv-2.9.git/hw/pci/pci.c
@@ -1419,7 +1419,9 @@ qemu_irq pci_allocate_irq(PCIDevice *pci
 void pci_set_irq(PCIDevice *pci_dev, int level)
 {
     int intx = pci_intx(pci_dev);
-    pci_irq_handler(pci_dev, intx, level);
+    if (intx >= 0) {
+        pci_irq_handler(pci_dev, intx, level);
+    }
 }
 
 /* Special hooks used by device assignment */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]