From 0441aa9a52a09f4766bd02fe454982bd15a26478 Mon Sep 17 00:00:00 2001 From: Mike Smith Date: Mon, 9 Oct 2000 00:43:45 +0000 Subject: [PATCH] Validate the PCI bus number that we fetch from our parent, since there's no guarantee that everything attached to *it* is a PCI bus. --- sys/dev/pci/pci.c | 7 +++++-- sys/pci/pci.c | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 07c8cd8616b..c0a4bb83c40 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -1060,7 +1060,7 @@ pci_add_children(device_t dev, int busno) static int pci_probe(device_t dev) { - static int once; + static int once, busno; device_set_desc(dev, "PCI bus"); @@ -1073,7 +1073,10 @@ pci_probe(device_t dev) * number to decide what bus we are probing. We ask the parent * pcib what our bus number is. */ - pci_add_children(dev, pcib_get_bus(dev)); + busno = pcib_get_bus(dev); + if (busno < 0) + return ENXIO; + pci_add_children(dev, busno); if (!once) { make_dev(&pcicdev, 0, UID_ROOT, GID_WHEEL, 0644, "pci"); diff --git a/sys/pci/pci.c b/sys/pci/pci.c index 07c8cd8616b..c0a4bb83c40 100644 --- a/sys/pci/pci.c +++ b/sys/pci/pci.c @@ -1060,7 +1060,7 @@ pci_add_children(device_t dev, int busno) static int pci_probe(device_t dev) { - static int once; + static int once, busno; device_set_desc(dev, "PCI bus"); @@ -1073,7 +1073,10 @@ pci_probe(device_t dev) * number to decide what bus we are probing. We ask the parent * pcib what our bus number is. */ - pci_add_children(dev, pcib_get_bus(dev)); + busno = pcib_get_bus(dev); + if (busno < 0) + return ENXIO; + pci_add_children(dev, busno); if (!once) { make_dev(&pcicdev, 0, UID_ROOT, GID_WHEEL, 0644, "pci");