[syslinux] [PATCH 3/3] modules: fix users of pci_scan() - check for NULL
Sebastian Herbszt
herbszt at gmx.de
Sun Mar 22 12:48:36 PDT 2009
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) {
More information about the Syslinux
mailing list