From 67e880fe9aca998a993716e113fdcad808480afc Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Tue, 28 Aug 2012 14:02:10 +0800 Subject: [PATCH] pci: Guard against wrong user supplied IRQ assignment --- sys/bus/pci/pci.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sys/bus/pci/pci.c b/sys/bus/pci/pci.c index 1fb6d954df..ad8b277983 100644 --- a/sys/bus/pci/pci.c +++ b/sys/bus/pci/pci.c @@ -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); + } } } -- 2.41.0