pci: Guard against wrong user supplied IRQ assignment
[dragonfly.git] / sys / bus / pci / pci.c
index 1fb6d95..ad8b277 100644 (file)
@@ -2701,8 +2701,17 @@ pci_assign_interrupt(device_t bus, device_t dev, int force_route)
                if (irq >= 255 || irq <= 0) {
                        irq = PCI_INVALID_IRQ;
                } else {
-                       BUS_CONFIG_INTR(bus, dev, irq,
-                           INTR_TRIGGER_LEVEL, INTR_POLARITY_LOW);
+                       if (machintr_legacy_intr_find(irq,
+                           INTR_TRIGGER_LEVEL, INTR_POLARITY_LOW) < 0) {
+                               device_printf(dev,
+                                   "hw.pci%d.%d.%d.%d.INT%c.irq=%d, invalid\n",
+                                   cfg->domain, cfg->bus, cfg->slot, cfg->func,
+                                   cfg->intpin + 'A' - 1, irq);
+                               irq = PCI_INVALID_IRQ;
+                       } else {
+                               BUS_CONFIG_INTR(bus, dev, irq,
+                                   INTR_TRIGGER_LEVEL, INTR_POLARITY_LOW);
+                       }
                }
        }