Remove "(void)cfgtype;" from com32/lib/pci/scan.c.
- Sebastian
Index: syslinux-3.74-pre11-2-g4fc8259/com32/lib/pci/scan.c
==================================================================---
syslinux-3.74-pre11-2-g4fc8259.orig/com32/lib/pci/scan.c
+++ syslinux-3.74-pre11-2-g4fc8259/com32/lib/pci/scan.c
@@ -441,7 +441,6 @@ struct pci_domain *pci_scan(void)
int cfgtype;
cfgtype = pci_set_config_type(PCI_CFG_AUTO);
- (void)cfgtype;
dprintf("PCI configuration type %d\n", cfgtype);
dprintf("Scanning PCI Buses\n");
@@ -521,7 +520,6 @@ void gather_additional_pci_config(struct
pciaddr_t a;
int cfgtype;
cfgtype = pci_set_config_type(PCI_CFG_AUTO);
- (void)cfgtype;
for (nbus = 0; nbus < MAX_PCI_BUSES; nbus++) {
bus = NULL;
Sebastian Herbszt
2009-Mar-22 19:48 UTC
[syslinux] [PATCH 2/3] pci: check for cfgtype == PCI_CFG_NONE
Check if configuration type is PCI_CFG_NONE.
- Sebastian
Index: syslinux-3.74-pre11-2-g4fc8259/com32/lib/pci/scan.c
==================================================================---
syslinux-3.74-pre11-2-g4fc8259.orig/com32/lib/pci/scan.c
+++ syslinux-3.74-pre11-2-g4fc8259/com32/lib/pci/scan.c
@@ -443,6 +443,9 @@ struct pci_domain *pci_scan(void)
cfgtype = pci_set_config_type(PCI_CFG_AUTO);
dprintf("PCI configuration type %d\n", cfgtype);
+ if (cfgtype == PCI_CFG_NONE)
+ return NULL;
+
dprintf("Scanning PCI Buses\n");
for (nbus = 0; nbus < MAX_PCI_BUSES; nbus++) {
@@ -519,7 +522,10 @@ void gather_additional_pci_config(struct
unsigned int nbus, ndev, nfunc, maxfunc;
pciaddr_t a;
int cfgtype;
+
cfgtype = pci_set_config_type(PCI_CFG_AUTO);
+ if (cfgtype == PCI_CFG_NONE)
+ return;
for (nbus = 0; nbus < MAX_PCI_BUSES; nbus++) {
bus = NULL;
Sebastian Herbszt
2009-Mar-22 19:48 UTC
[syslinux] [PATCH 3/3] modules: fix users of pci_scan() - check for NULL
Check for pci_scan() == NULL.
- Sebastian
Index: syslinux-3.74-pre11-2-g4fc8259/com32/hdt/hdt-common.c
==================================================================---
syslinux-3.74-pre11-2-g4fc8259.orig/com32/hdt/hdt-common.c
+++ syslinux-3.74-pre11-2-g4fc8259/com32/hdt/hdt-common.c
@@ -326,13 +326,15 @@ void detect_pci(struct s_hardware *hardw
return;
hardware->pci_detection = true;
+ hardware->nb_pci_devices = 0;
/* Scanning to detect pci buses and devices */
hardware->pci_domain = pci_scan();
+ if (!hardware->pci_domain)
+ return;
/* Gathering addtional information*/
gather_additional_pci_config(hardware->pci_domain);
- hardware->nb_pci_devices = 0;
struct pci_device *pci_device;
for_each_pci_func(pci_device, hardware->pci_domain) {
hardware->nb_pci_devices++;
Index: syslinux-3.74-pre11-2-g4fc8259/com32/modules/pcitest.c
==================================================================---
syslinux-3.74-pre11-2-g4fc8259.orig/com32/modules/pcitest.c
+++ syslinux-3.74-pre11-2-g4fc8259/com32/modules/pcitest.c
@@ -102,6 +102,10 @@ int main(int argc, char *argv[])
/* Scanning to detect pci buses and devices */
printf("PCI: Scanning PCI BUS\n");
pci_domain = pci_scan();
+ if (!pci_domain) {
+ printf("PCI: no devices found!\n");
+ return 1;
+ }
struct pci_device *pci_device;
for_each_pci_func(pci_device, pci_domain) {