This is a note to let you know that I've just added the patch titled

    Driver core: treat unregistered bus_types as having no devices

to the 3.4-stable tree which can be found at:
    
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     driver-core-treat-unregistered-bus_types-as-having-no-devices.patch
and it can be found in the queue-3.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.


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

From: Bjorn Helgaas <[email protected]>

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
again:

    mach_reboot_fixups
      pci_get_device
        ..
          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: https://lkml.org/lkml/2012/12/28/75 ("[PATCH] x86, reboot: skip
reboot_fixups in early boot phase")

Reported-by: Joonsoo Kim <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
 drivers/base/bus.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -294,7 +294,7 @@ int bus_for_each_dev(struct bus_type *bu
        struct device *dev;
        int error = 0;
 
-       if (!bus)
+       if (!bus || !bus->p)
                return -EINVAL;
 
        klist_iter_init_node(&bus->p->klist_devices, &i,
@@ -328,7 +328,7 @@ struct device *bus_find_device(struct bu
        struct klist_iter i;
        struct device *dev;
 
-       if (!bus)
+       if (!bus || !bus->p)
                return NULL;
 
        klist_iter_init_node(&bus->p->klist_devices, &i,


Patches currently in stable-queue which might be from [email protected] are

queue-3.4/driver-core-treat-unregistered-bus_types-as-having-no-devices.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to