Patchwork [3.5.y.z,extended,stable] Patch "Driver core: treat unregistered bus_types as having no" has been added to staging queue

mail settings
Submitter Luis Henriques
Date Feb. 26, 2013, 4:13 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/223292/
State New
Headers show


Luis Henriques - Feb. 26, 2013, 4:13 p.m.
This is a note to let you know that I have just added a patch titled

    Driver core: treat unregistered bus_types as having no

to the linux-3.5.y-queue branch of the 3.5.y.z extended stable tree 
which can be found at:;a=shortlog;h=refs/heads/linux-3.5.y-queue

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.5.y.z tree, see



From 2ed4f2b057593bca9ba19e506e0c8f84691b4b86 Mon Sep 17 00:00:00 2001
From: Bjorn Helgaas <>
Date: Tue, 29 Jan 2013 16:44:27 -0700
Subject: [PATCH] Driver core: treat unregistered bus_types as having no

commit 4fa3e78be7e985ca814ce2aa0c09cbee404efcf7 upstream.

A bus_type has a list of devices (klist_devices), but the list and the
subsys_private structure that contains it are not initialized until the
bus_type is registered with bus_register().

The panic/reboot path has fixups that look up devices in pci_bus_type.  If
we panic before registering pci_bus_type, the bus_type exists but the list
does not, so mach_reboot_fixups() trips over a null pointer and panics

          bus_find_device(&pci_bus_type, ...)
            bus->p is NULL

Joonsoo reported a problem when panicking before PCI was initialized.
I think this patch should be sufficient to replace the patch he posted
here: ("[PATCH] x86, reboot: skip
reboot_fixups in early boot phase")

Reported-by: Joonsoo Kim <>
Signed-off-by: Bjorn Helgaas <>
Signed-off-by: Greg Kroah-Hartman <>
Signed-off-by: Luis Henriques <>
 drivers/base/bus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)



diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 2bcef65..287b7e2 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -293,7 +293,7 @@  int bus_for_each_dev(struct bus_type *bus, struct device *start,
 	struct device *dev;
 	int error = 0;

-	if (!bus)
+	if (!bus || !bus->p)
 		return -EINVAL;

 	klist_iter_init_node(&bus->p->klist_devices, &i,
@@ -327,7 +327,7 @@  struct device *bus_find_device(struct bus_type *bus,
 	struct klist_iter i;
 	struct device *dev;

-	if (!bus)
+	if (!bus || !bus->p)
 		return NULL;

 	klist_iter_init_node(&bus->p->klist_devices, &i,