[PATCH] pci: fix no_pci_devices() #2

From: Vegard Nossum
Date: Sat Dec 20 2008 - 06:08:18 EST


In short, no_pci_devices() should not use bus_find_device() before
initcalls have run, because the pci bus structure has not been
initialized yet.

Reference: http://lkml.org/lkml/2008/12/20/21

Cc: Greg KH <gregkh@xxxxxxx>
Cc: Pekka Enberg <penberg@xxxxxxxxxxxxxx>
Signed-off-by: Vegard Nossum <vegard.nossum@xxxxxxxxx>
---
drivers/base/bus.c | 1 +
drivers/pci/probe.c | 3 +++
2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 5aee1c0..5e83faf 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -931,6 +931,7 @@ bus_devices_fail:
bus_uevent_fail:
kset_unregister(&bus->p->subsys);
kfree(bus->p);
+ bus->p = NULL;
out:
return retval;
}
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 003a9b3..d561be7 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -35,6 +35,9 @@ int no_pci_devices(void)
struct device *dev;
int no_devices;

+ if (!pci_bus_type.p)
+ return 1;
+
dev = bus_find_device(&pci_bus_type, NULL, NULL, find_anything);
no_devices = (dev == NULL);
put_device(dev);
--
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/